Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (754)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (842)
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  
  Need help with collision detection.  (Read 809 times)
0 Members and 1 Guest are viewing this topic.
Offline UnluckyDevil

Junior Newbie

« Posted 2013-05-12 03:10:35 »


I have just started playing with Java game development.  After reading some articles on the web and following Bucky Roberts tutorial on YouTube this is what I have managed to come up with this amazing game.

It is a 10 x 10 grid with a greed dot representing the player, red dots representing bad guys, and black dots representing impassible terrain.

The player can be moved around using the wasd keys, the red dots move on their own, and the black dots don't move at all.

The problem I have run into is that the green dot can move on top of the red dots and vice verse, and the red dots can move on top of each other.  This should not happen.  It is weird because the greed dot can only move onto the red dot on the vertical axis.  It seems to work like I want and expect on the horizontal axis.

This is my first post and there is a lot of code... I hope I got it all int the pastebin correctly.
Offline Jimmt
« League of Dukes »

JGO Kernel

Medals: 167
Projects: 5
Exp: 6 years

« Reply #1 - Posted 2013-05-12 03:17:04 »

Pastebin link because you forgot to put it:
I don't quite understand, green dots only move vertically and what about red movement? Your explanation isn't too clear, please elaborate/use some screenshots.
Offline UnluckyDevil

Junior Newbie

« Reply #2 - Posted 2013-05-12 07:54:14 »

Thanks for getting that link in there for me.

Sadly I can't get a screenshot for you right now.

Let me see if I can explain it better.

The game is set up as a 10 by 10 grid of squares.  Each square may be empty, or occupied by an Entity(the player, an enemy, or an obstacle).

The player is represented by a green dot that can move around to the different squares.  Pressing the a key will move the player to the square on his left, pressing w will move the player to the square above him, pressing d will move the player to the square on his right, and pressing s will move the player to the square below him.

Enemies are represented by red dots that can move around to different squares.  The red dots move to a randomly determined square above, below, to the right, or to the left on a timed delay.

Obstacles are represented by black dots that do not move.

None of the Entities should be able to occupy the same square at the same time.

The problem is the player can move onto the same square as an enemy if the player moves from above or below it.

Pages: [1]
  ignore  |  Print  

DesertCoockie (22 views)
2018-05-13 18:23:11

nelsongames (73 views)
2018-04-24 18:15:36

nelsongames (68 views)
2018-04-24 18:14:32

ivj94 (751 views)
2018-03-24 14:47:39

ivj94 (81 views)
2018-03-24 14:46:31

ivj94 (605 views)
2018-03-24 14:43:53

Solater (97 views)
2018-03-17 05:04:08

nelsongames (170 views)
2018-03-05 17:56:34

Gornova (388 views)
2018-03-02 22:15:33

buddyBro (1048 views)
2018-02-28 16:59:18
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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‑
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!