Thanks to some great and kind advices, I could fix the problem.
And then I added many things prepared. I'm going to work more, so this is for-now form.
← and → ... Move left or right
↑........... Enter the door (Move to next stage)
↓........... Activate switch
〇........... Jump(on the ground), Air dash(in the air)
×........... Nothing for now.
*The title "Kagiventure" comes from "鍵(Kagi, key in Japanese)" and "adventure".
Now I'm making a new platformer which uses some gimmicks.
And then I got a problem.
I divided each levels with their level's start, end, top and bottom.
They mean level's left end, right end, up end and down end.
And the gimmicks such as key and key door should work only in the level where you are(= curst, CURrent STage).
But it seems the gimmicks work in all levels. If you get a key in level 1, then all door will open...
I want to fix it, but can't get how. If anyone knows the solution, please tell me how.
Thanks in advance.
EDIT: The problem was solved. Thank you so much for teaching!
*I learned the code about gimmicks from "mea's castle", a pico-8 metroidvania.
ok I might be wrong, but I'm going to have a guess at this one. in this section:
function stage_update() local map_start=split("0,0,257,897") local map_end=split("256,256,384,1024") local map_top=split("0,129,0,0") local map_bottom=split("128,256,256,384") for x=map_start[curst],map_end[curst] do for y=map_top[curst],map_bottom[curst] do v=mget(x,y) if v==65 then if key then mset(x,y,66) end
It looks like you're looping through each pixel in the for loops. But with v=mget(x,y) you're looking at the tile on the map (which is the same as 8x8 pixels).
so where you're thinking you're going over the first say 200 pixels, you're actually checking the first 200 tiles which is way bigger than the stage, and you might be changing all the doors throughout the entire map.
I think the solution is to make the for loops smaller, maybe go from x=map_start[curst]/8 to map_end[curst]/8 (and the same for the y's).
Maybe you could put a counter in that loops and print the counter to screen later and see how many times it goes through the loops to check.
I hope that's helpful. If it's not I'll try testing it out on my end.
EDIT: sorry I only just realised I can download the game and run it on my own machine (what a great feature)
yeah if you change the loops in stage_update() to this:
for x=map_start[curst]/8,map_end[curst]/8 do for y=map_top[curst]/8,map_bottom[curst]/8 do
then that fixes everything.
[Please log in to post a comment]