Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  AI FOR MY GAME ???  (Read 1038 times)
0 Members and 1 Guest are viewing this topic.
Offline GNecro1
« Posted 2013-07-31 11:22:57 »

I want to make an AI that goes to one direction and then to other but it gets to location that i gave it to go ?and also i want to make enemies shoot at my base at random times !!! the player and enemies can just go left right up and down
i wanted it that way Cheesy !if you understand me .... I am making a game like TD/RTS/FPS it is TD but you can control the tank on the screen and shoot the enemies and you get money and you can make towers that shoot to ... in multiplayer you will attack other players and see who will survive .....
SCREEN SHOT SO FAR




so does anyone know how can i make that kind of AI Huh

JAVAAAAAAAAAAAAAAAA Freak Cheesy!
Online Herjan
« Reply #1 - Posted 2013-07-31 11:44:07 »

Ok, I dont know what u want with walking leftrightupdown, but for shooting at random times, I would do this:

int randomShot = (int) (Math.random()*(Math.random()*20));
if(randomShot == 0){
 shootThisBaby();
}

Math.random()*20 is the amount of possibilities, so if that is 10, randomShot can be 0,1,2 - 9... So it has 10% chance to shoot.

Offline GNecro1
« Reply #2 - Posted 2013-07-31 11:51:37 »

when i said right left up down i meant that it the game is tile based example you move right that is so you are pressing
the letter D and if you press W (i mean up) you will go up and if you press the both you will right or down you cant go in between if you understand me but is just for the player enemies cant go in between also but you cant control them Huh
.......
 

JAVAAAAAAAAAAAAAAAA Freak Cheesy!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Online Herjan
« Reply #3 - Posted 2013-07-31 12:15:38 »

Random directions:



int direction = (int) (Math.random() *4);
Mob.changeDirection(direction);

In Mob(enemy)
public final int left = 0, right = 1, down = 2, up = 3;
public void changeDirection(int dir){
  switch(dir)
  case left:
    xBlock++;
  case right:
    xBlock--; //etc.
}

Offline GNecro1
« Reply #4 - Posted 2013-07-31 12:18:36 »

but i need it to go at block location 10 in x and 6 in y and that it goes in random locations 20 an 12 are the max x , y

JAVAAAAAAAAAAAAAAAA Freak Cheesy!
Online Herjan
« Reply #5 - Posted 2013-07-31 13:19:08 »

but i need it to go at block location 10 in x and 6 in y and that it goes in random locations 20 an 12 are the max x , y

I dont know what you mean, however

if(x==20 && (direction == left || direction == right) ) direction = down;
Watch some tutorials on youtube or so...
Learn to think, I don't want now to get this reaction: "NOW IT GOES ALWAYS DOWN", previous reply I told u how to do random things...  Wink Good luck

Offline GNecro1
« Reply #6 - Posted 2013-07-31 13:41:36 »

i was thinking the same thing but i dont want it that way but thanks Cheesy Cheesy

JAVAAAAAAAAAAAAAAAA Freak Cheesy!
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (26 views)
2014-07-24 01:59:36

Riven (25 views)
2014-07-23 21:16:32

Riven (20 views)
2014-07-23 21:07:15

Riven (22 views)
2014-07-23 20:56:16

ctomni231 (51 views)
2014-07-18 06:55:21

Zero Volt (46 views)
2014-07-17 23:47:54

danieldean (37 views)
2014-07-17 23:41:23

MustardPeter (40 views)
2014-07-16 23:30:00

Cero (56 views)
2014-07-16 00:42:17

Riven (55 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!