Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
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 356 times)
0 Members and 1 Guest are viewing this topic.
Offline UnluckyDevil

Junior Newbie





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

Hello,

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: 136
Projects: 4
Exp: 3 years



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

Pastebin link because you forgot to put it: http://www.java-gaming.org/index.php?action=pastebin&hex=6d3725e785c
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  
 
 
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.

Longarmx (39 views)
2014-10-17 03:59:02

Norakomi (29 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (28 views)
2014-10-15 16:18:58

TehJavaDev (57 views)
2014-10-14 00:39:48

TehJavaDev (57 views)
2014-10-14 00:35:47

TehJavaDev (48 views)
2014-10-14 00:32:37

BurntPizza (64 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (78 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!