Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (741)
Games in Android Showcase (225)
games submitted by our members
Games in WIP (823)
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  
  2D side scroller platformer - detecting collisions with big movement intervals  (Read 3509 times)
0 Members and 1 Guest are viewing this topic.
Offline Porlus

Junior Devvie





« Posted 2014-11-11 21:20:23 »

Hi all,
I'm making a 2D side scrolling platformer, where the platforms are effectively a 2D array of tiles rendered in much the same way as a standard 2D top-down game (0, 0) top left hand corner to (mapWidth * tileWidth, mapHeight * tileHeight) which is the bottom right hand corner. The player can land on tiles, depending on whether they're set in the array, or walk into them, or bang their head on them, etc.

Gravity is acting on the player, so if they aren't standing on a tile, they'll keep falling faster, until they reach the end of the tile map, then they'll fall forever. Everything's going fine, but I'm determining collisions much in the same way as I've been doing in the top down games, whereby I divide the player's position + delta movement, divide each of the player's surrounding corners by the tileWidth and tileHeight, then loop through them, checking if they're passable and if one isn't, I stop the player from moving in that axis.

That's all fine for those games because the player doesn't move by a significant amount at a time, but obviously when gravity's introduced the player begins to clip through tiles, because the tile features between the player's position and the player's position + delta movement.

Are there any standard methods of solving this problem as at the moment, when the player's falling more than, say, 50 blocks, they can clip straight through entire platforms.

If anyone could give me any tips on this I'd appreciate it.
Offline ags1

JGO Kernel


Medals: 356
Projects: 7


Make code not war!


« Reply #1 - Posted 2014-11-11 23:10:28 »

When the delta is greater than block size, test for collisions along the path in half-block steps.

Offline Porlus

Junior Devvie





« Reply #2 - Posted 2014-11-12 00:00:13 »

Hiya, thanks for the reply. Smiley Sounds good. I'll have a play around with it. Cheers!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline HeroesGraveDev

JGO Kernel


Medals: 382
Projects: 11
Exp: 4 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #3 - Posted 2014-11-12 00:34:32 »

Having a terminal velocity could help avoid the problem in the first place rather than solving it.

Although if you want the player to move at insanely fast speeds it won't do.

Offline Porlus

Junior Devvie





« Reply #4 - Posted 2014-11-12 18:16:38 »

Yeah, that's a good point. I probably should have set one. Tongue It's not crucial that entities move that fast. Ah well, maybe I'll set one for the hell of it.

Anyway, got this all working now. Cheers for your help guys!
Pages: [1]
  ignore  |  Print  
 
 

 
xxMrPHDxx (1 views)
2017-11-21 16:10:57

Ecumene (113 views)
2017-09-30 02:57:34

theagentd (148 views)
2017-09-26 18:23:31

cybrmynd (245 views)
2017-08-02 12:28:51

cybrmynd (241 views)
2017-08-02 12:19:43

cybrmynd (241 views)
2017-08-02 12:18:09

Sralse (256 views)
2017-07-25 17:13:48

Archive (874 views)
2017-04-27 17:45:51

buddyBro (1026 views)
2017-04-05 03:38:00

CopyableCougar4 (1578 views)
2017-03-24 15:39:42
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

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
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!