Log In  

Hey all, working on an endless runner and running (lol) into a couple issues.

Here's the cart:

Cart #kebahugosi-0 | 2021-12-30 | Code ▽ | Embed ▽ | No License

Basically I can't seem to get the 'enemy sprites' to actually kill the player. I've given them their own tables of values, flags etc but I don't know how exactly to check their flags for proper collision. Alternatively, I would maybe like to generate the enemies using the map_gen() function so the placement is relatively random, and that works to kill the player, but then I can't make them move.

This goes hand in hand with making the runner go on indefinitely until player death - currently it only generates 8 screens and then repeats. Another forum member mentioned I should pick a midpoint then 'copy' the second half of of the map back at start, move the player instantly, and then generate the second half again - but I have no clue how to go about that.

Any help would be greatly appreciated!!

P#103843 2021-12-30 20:52

oh right, common mistake for the enemies collisions! you seem to have them as objects, and are using collide_map for all death checks. you'd have to manually check to see if the player is overlapping an enemy, as mget simply fetches from the map, and not sprites in general drawn to the screen.

for the suggestion to clone back a portion of the map each time the player passes a certain point, memcpy() is likely the thing needed here. check if the player is past halfway, and if so copy back the map data a few screens, then go through everything that isn't part of the map and move it back the same amount. (e.g. the player, the enemies, the point where more level is being generated)

P#104013 2022-01-01 12:25

Hi, @ssarkar.

To do a collision check with objects that are not part of the map, you can use ABS() to check the distance both horizontally and vertically between them and the player.

Cart #tehehejuze-0 | 2022-01-01 | Code ▽ | Embed ▽ | No License

Run the code above to see how this is done. If you start out on top of an object, just press CTRL+R until you are not and can navigate.

This subject was also discussed in length regarding collision by pixels HERE (code included):

https://www.lexaloffle.com/bbs/?tid=36034

P#104034 2022-01-01 18:42 ( Edited 2022-01-01 19:04)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-29 11:11:28 | 0.029s | Q:20