Java-Gaming.org
 Featured games (81) games approved by the League of Dukes Games in Showcase (497) Games in Android Showcase (114) games submitted by our members Games in WIP (563) 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
 Best collision pixel perfect system EVER, without physics (T_T)  (Read 2355 times) 0 Members and 1 Guest are viewing this topic.
iox

Junior Newbie

 « Posted 2013-03-29 17:15:11 »

Sup, community, I'm newbie. I'm creating a game with elements of classic platformer (Mario, etc...) on Slick2D. I made a pixel perfect, quick and simple system collision, I think. You can download and try for yourself. But I have some problems with physics (jump, gravity, acceleration). I learned a lot of stuff, soo... and I have no idea how it works. Please, help! T__T

Hello, %username%!
iox

Junior Newbie

 « Reply #1 - Posted 2013-03-29 17:20:12 »

Oh, sorry...

 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17 `// CHECKcollides(Level level) {   boolean result = false;      // TOP      if (is_tile_solid(x+1, y, level)) result = true;      if (is_tile_solid(x+w-2, y, level)) result = true;      // BOTTOM      if (is_tile_solid(x+1, y+h-1, level)) result = true;      if (is_tile_solid(x+w-2, y+h-1, level)) result = true;      // LEFT      if (is_tile_solid(x, y+1, level)) result = true;      if (is_tile_solid(x, y+h-2, level)) result = true;      // RIGHT      if (is_tile_solid(x+w-1, y+1, level)) result = true;      if (is_tile_solid(x+w-1, y+h-2, level)) result = true;   return result;}`

 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19 `// MOVE ENTITYvoid move(Level level, int delta) {   float axs = Math.abs(xs);   float ays = Math.abs(ys);   float max = ays;   if (axs > ays) { max = axs; }   float xstep = xs/max;   float ystep = ys/max;   float axstep = Math.abs(xstep);   float aystep = Math.abs(ystep);   while (axs > 0 || ays > 0) {      x += xstep;      if (collides(level)) { x -= xstep; }      y += ystep;      if (collides(level)) { y -= ystep; }      axs -= axstep;      ays -= aystep;   }}`

 1  2  3  4  5  6  7  8  9  10 `// COLLISIONboolean is_tile_solid(float xpos, float ypos, Level level) {   int i = (int) ((xpos) / Level.tilesize);   int j = (int) ((ypos) / Level.tilesize);    if (i >= 0 && i < level.getMapWidth() && j >= 0 && j < level.getMapHeight()) {      if ( level.getMap().getTileId(i, j, Cnst.COLLISION) == Cnst.SOLID ) return true;      else return false;   }   return true;}`

Hello, %username%!
opiop65

JGO Kernel

Medals: 154
Projects: 7
Exp: 3 years

JumpButton Studios

 « Reply #2 - Posted 2013-03-29 22:22:54 »

First, what specifically is your problem? No one can help you if you don't actually tell us what is wrong. Second, you know you just gave out the source code to your game right? On your website, you need to actually export the .jar file instead of giving us your workspace.

 Games published by our own members! Check 'em out!
Sammidysam
 « Reply #3 - Posted 2013-03-29 22:40:45 »

If you are using Slick2D you could use Rectangles for collision.  They're pretty simple and easy to use.
tyeeeee1
 « Reply #4 - Posted 2013-03-29 23:27:57 »

First, what specifically is your problem? No one can help you if you don't actually tell us what is wrong. Second, you know you just gave out the source code to your game right? On your website, you need to actually export the .jar file instead of giving us your workspace.

I believe that this post was just to show off the code that he wrote. I've based this conclusion off of the topic title.
opiop65

JGO Kernel

Medals: 154
Projects: 7
Exp: 3 years

JumpButton Studios

 « Reply #5 - Posted 2013-03-29 23:35:28 »

First, what specifically is your problem? No one can help you if you don't actually tell us what is wrong. Second, you know you just gave out the source code to your game right? On your website, you need to actually export the .jar file instead of giving us your workspace.

I believe that this post was just to show off the code that he wrote. I've based this conclusion off of the topic title.

Ah I feel stupid now. OP, sorry for the criticism!

matheus23

JGO Kernel

Medals: 107
Projects: 3

You think about my Avatar right now!

 « Reply #6 - Posted 2013-03-29 23:40:26 »

I believe that this post was just to show off the code that he wrote. I've based this conclusion off of the topic title.

But I think he's still looking for help:
Please, help! T__T

See my:
My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Axeman

Senior Member

Medals: 7

 « Reply #7 - Posted 2013-03-30 00:35:20 »

But I have some problems with physics (jump, gravity, acceleration). I learned a lot of stuff, soo... and I have no idea how it works. Please, help! T__T

Check this out: http://www.java-gaming.org/topics/how-to-start-with-lwjgl-physics/29112/view.html

ItÂ´s got a couple of really good links where you can read up on game physics.
relminator
 « Reply #8 - Posted 2013-03-30 10:53:38 »

You know this:

 1  2  3  4  5  6  7  8  9  10  11 `  // COLLISION   boolean is_tile_solid(float xpos, float ypos, Level level) {   int i = (int) ((xpos) / Level.tilesize);   int j = (int) ((ypos) / Level.tilesize);    if (i >= 0 && i < level.getMapWidth() && j >= 0 && j < level.getMapHeight()) {      if ( level.getMap().getTileId(i, j, Cnst.COLLISION) == Cnst.SOLID ) return true;      else return false;   }   return true;}`

This isn't a pixel-perfect test right?

Unless your map itself is made of game pixels which is quite a memory hog.

iox

Junior Newbie

 « Reply #9 - Posted 2013-03-30 20:51:59 »

Sorry, that is not expressed. I need a pseudocode of jump & gravity.

Hello, %username%!
 Games published by our own members! Check 'em out!
matheus23

JGO Kernel

Medals: 107
Projects: 3

You think about my Avatar right now!

 « Reply #10 - Posted 2013-03-30 22:24:27 »

Sorry, that is not expressed. I need a pseudocode of jump & gravity.
https://www.google.de/search?q=platformer+jump+gravity+site%3Ajava-gaming.org

See my:
My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
iox

Junior Newbie

 « Reply #11 - Posted 2013-03-30 22:37:01 »

Okay.jpg
I apologize for the stupid question.

Hello, %username%!
wreed12345

JGO Knight

Medals: 24
Projects: 2
Exp: 2 years

http://linebylinecoding.blogspot.com/

 « Reply #12 - Posted 2013-03-30 22:39:13 »

http://www.java-gaming.org/topics/making-a-sprite-jump/28350/msg/257412/view.html
definitely check that out! I asked a similar question about jumping / gravity

matheus23

JGO Kernel

Medals: 107
Projects: 3

You think about my Avatar right now!

 « Reply #13 - Posted 2013-03-30 22:48:08 »

http://www.java-gaming.org/topics/making-a-sprite-jump/28350/msg/257412/view.html
definitely check that out! I asked a similar question about jumping / gravity

Ha ha. Exactly what i was originally thinking Tod post, but couldn't find it

See my:
My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
iox

Junior Newbie

 « Reply #14 - Posted 2013-03-30 22:55:02 »

http://www.java-gaming.org/topics/making-a-sprite-jump/28350/msg/257412/view.html
definitely check that out! I asked a similar question about jumping / gravity
Thanx! When I'm done, I'll share source code.

Hello, %username%!
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.
 BurntPizza (21 views) 2014-09-19 03:14:18 Dwinin (35 views) 2014-09-12 09:08:26 Norakomi (62 views) 2014-09-10 13:57:51 TehJavaDev (87 views) 2014-09-10 06:39:09 Tekkerue (42 views) 2014-09-09 02:24:56 mitcheeb (65 views) 2014-09-08 06:06:29 BurntPizza (47 views) 2014-09-07 01:13:42 Longarmx (35 views) 2014-09-07 01:12:14 Longarmx (40 views) 2014-09-07 01:11:22 Longarmx (36 views) 2014-09-07 01:10:19
 BurntPizza 37x Riven 18x Rayvolution 17x princec 17x basil_ 16x ags1 16x KevinWorkman 15x kevglass 12x LiquidNitrogen 11x nsigma 11x theagentd 11x HeroesGraveDev 9x The Lion King 7x Gibbo3771 6x cylab 6x EgonOlsen 6x
 List of Learning Resources2014-08-16 10:40:00List of Learning Resources2014-08-05 19:33:27Resources for WIP games2014-08-01 16:20:17Resources for WIP games2014-08-01 16:19:50List of Learning Resources2014-07-31 16:29:50List of Learning Resources2014-07-31 16:26:06List of Learning Resources2014-07-31 11:54:12HotSpot Optionsby dleskov2014-07-08 01:59:08
 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