Results 1 to 2 of 2
Thread: Java game dev, Basic AI
- 12-07-2010, 07:08 AM #1
Member
- Join Date
- Oct 2010
- Posts
- 12
- Rep Power
- 0
Java game dev, Basic AI
Greetings
I have a project going on and i am responsible for programming the AI for the random monsters that will roam our map.
I got the monster to bounce between left and right or up and down. What i havnt understood is if its possible for it to check if it can go left/right if its going up/down. I have set it up like
This part works, it goes down and then up again but i dont see how i could make it a chance it tries to go left or right.Java Code:if (e1.intersects(b2)) ec.eSpeed(-1); //ec.right(!true); if (e1.getY() == 0) { ec.eSpeed(1); // ec.right(true); } if (e1.getY() == 665) { ec.eSpeed(-1); // ec.right(true); }
This part is what i would like to use, i have set up the booleans for the four directions but as you can see my first If statement is enaged again as soon as the monster stops to intersect the block (b2 is just a made up rectangle). So it goes to the right, intersects, goes down so it doesnt intersect anymore but then continues right. I would like for it to just stop moving right and continue on its path down.Java Code:if (!e1.intersects(b2)){ ec.right(true); ec.move_right(); } if (e1.intersects(b2)){ ec.right(!true); ec.down(true); ec.move_down(); }
I dont know if you need more code, its quite heavy, well atleast for me as a new guy.
Well any thoughts or help is more then welcome
//Kerrai
- 12-07-2010, 10:49 AM #2
Member
- Join Date
- Dec 2010
- Posts
- 27
- Rep Power
- 0
Similar Threads
-
Basic Java help, AIM?
By jkswebsite in forum New To JavaReplies: 4Last Post: 07-11-2012, 06:17 PM -
Basic Football management game
By Wakesta in forum Java GamingReplies: 1Last Post: 07-05-2010, 10:50 PM -
Basic counter timer for a game?
By Laura in forum New To JavaReplies: 1Last Post: 04-18-2010, 01:46 AM -
Beginner at very basic game development
By codermom in forum New To JavaReplies: 4Last Post: 01-20-2009, 04:22 AM -
basic java help
By adred in forum New To JavaReplies: 0Last Post: 03-08-2008, 12:36 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks