• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

[SOLVED] Need help with a hybrid solid/tileset slope engine.

D

Danei

Guest
Break it down into parts and see if you can narrow down where the issue is. For example, make sure the array you're setting initially has the correct values, which you can check in the debugger or just print debug messages. Your illustration has a blue background, so hopefully you're not using a blue background in your actual game while checking for black pixels.
If that's all good, then make sure your inFloor function is returning the correct values in each case that you're using it.
Presumably you aren't mirroring/rotating or using bitmask data on your tiles, but if you are you'll need to account for that in your checks.

Based on what you said it doesn't seem like this issue has anything to do with your use of solid objects, but you could try commenting out all the solids code just to make sure it's not part of the problem.
 
N

nickvm98

Guest
One of the first things I checked was the values for the heights array and for some reason they are all set to 30. Changing the background to an actual c_black image fixed another issue I had where the player would snap to the tops of slopes shown in the image of my other post. But the issue is the player still not being able to walk up a slope.

I've checked the infloor script and it's not the problem.
 
D

Danei

Guest
If I'm not mistaken, this bit of code is the one that should be lifting you up onto the slope, right?

Code:
var _floordist=scr_infloor(tilemap,x,bbox_bottom+yvel);
if _floordist>=0 {
         y+=yvel;
         y-=(_floordist+1);
         yvel=0;
         _floordist=-1;
    }
I'd say put some breakpoints in there and step through it in the debugger and find out exactly what's happening. This will enable you to make sure that the issue isn't caused by something later in your code "undoing" the y position offset, and narrow it down further.
 
N

nickvm98

Guest
That code just moves the player by its y velocity, places the player 1 pixel above the slope and resets both values. The only problem with it is I ran the debugger and floordist returns -1 when inside a slope. The player still can't interact with a slope.
I think the problem is the way global.heights is set. They are all set to 30 for some reason despite there being a c_black background.
 
D

Danei

Guest
That'll do it. So you need to figure out why they aren't being set correctly. Is your viewport smaller than your room and placed somewhere other than the top-left corner, by any chance? If your view doesn't line up with where the tileset is being drawn, I think the pixels won't be right because you're checking the application surface.
 
N

nickvm98

Guest
It worked. The viewport of my game only worked during the step event. By duplicating it in the create event it worked.

Thanks so much. I can finally start level designing and adding hills.
 
Top