Log In  

I am a noob at Pico 8 and I really need help with map collisions. I tried using Nerdyteacher tutorials but they don't work. I tried using the simple collision function cartridge and it also does not work and I don't know what to do now.

P#142100 2024-02-28 02:08 ( Edited 2024-02-28 02:10)

2

Hi mew1234,
Is it the Game Mechanics: Advanced Movement tutorial? Can you get anything to appear on the screen at all (like a simple print("hello world"))?
You haven't given a great description of the problem so it's hard to know where to start helping you, but here's some general advice since you mentioned being new to Pico 8:

  • Run your game at each step to check if it's working.
  • Back up your working code to notepad for long or complex steps (or for making big changes, or for anything really lol) in case it crashes by the time you reach a good testing point. Doing this will save you a lot of headaches in the long run.
  • It's tempting to copy-paste code, but it's generally safer to type out your code to avoid mixing up variable names.
  • Indent your code after IF...THEN / WHILE...DO / FUNCTION F() etc. to make it easier to catch missing ENDs.
P#142114 2024-02-28 13:12
1

Good advice @Verb! You can also try this simple collision demo cart

Cart #koz_colldemo-0 | 2024-01-02 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2

Use the "Code" dropdown to view the source code. The basic idea here is to take a pixel (two really, one for each forward corner) and use mget(x/8,y/8) to get the tile type from the map at each point, then use fget(thetile,0) to check if that kind of tile has flag 0 set (settable in the sprite editor). If they have that flag, we consider it a wall and don't allow the move. This is pretty basic though, and not necessarily the best way for your game. Things get more complicated if you want to, let's say, move faster than one pixel per frame.

You should also be able to load this in the P8 executable by using the command load #koz_colldemo and then using run

Let me know if you have any questions or if any of these steps are not working for you.

P#142145 2024-02-28 18:35 ( Edited 2024-02-28 18:53)

Thanks for the help. It was really helpful because I spend a 4 hour trying to make other code work.

P#142155 2024-02-28 20:09 ( Edited 2024-02-28 20:14)

[Please log in to post a comment]