I love how he actually explains things as opposed to most coding tutorials. It makes it easy to actually understand what's happening rather than just copying from the video.
This one was tricky, I've had to come back to it to check my understanding again. Thank you. I hope to be able to make a version from memory (without checking these tutorials) soon :)
So I've typed the functions for Tiles MGET, FGET and movement, however my player sprite is not being able to move past floor tiles after a certain point of the map. Some wall tiles work and some dont. would you happen to know why? cant seem to find an answer
How do I fix this error it keeps coming each time I press Control+r: Runtime error line 25 tab 1 Return not is_tile(wall,x,y) Attempted call global “is_tile” (A nil value) In can_move line 25 (tab 1) In move_player line 24 (tab 2) In _update line 9 (tab 0) At line 0 (tab 0) I don’t know what to do I am stuck and this is my first time using pico 8
Sorry, I have another problem. Here's my code for the movement options, it says that i'm calling a nil value again in the update function. FOR TAB 2: function move_player() newx=p.x newy=p.y
if (btnp(➡️)) newx-=1 if (btnp(⬅️)) newx+=1 if (btnp(⬆️)) newy-=1 if (btnp(⬇️)) newy+=1
if (canmove(newx,newy)) then p.x=mid(0,newx,127) p.y=mid(0,newy,63) else sfx(0) end end FOR TAB 1: function is_tile(x,y,tile_type) tile=mget(x,y) has_flag=fget(tile,tile_type) return has_flag end function can_move(x,y) return not is_tile(x,y,wall) end Thanks again!
Never mind, I figured out the problem, it was basically just me typing incorrectly and forgetting basic things. Thanks for creating this tutorial series by the way, it's helped me out a lot
@@cheshirecreeper3743 Glad you caught the error! My only advice would be to try not to get too frustrated with problems like that. Those little errors are more common than you might think. I have been programming for 30 years and I make those kinds of mistakes *all the time*. Literally. Usually the error message will point you to the right line, but not always. But 9 times out of 10 it's a little error like that. I'm happy to help any time you need it.
Double check when you're listening for the button presses in the move_player() function that you have newx-=1 for the left button and newx+=1 for the right button.
i dont know why, but my character doesnt move like that, its moves "Diagonaly", What am I doing wrong? the code: --player code function make_player() p={} p.x=3 p.y=2 p.sprite=1 p.keys=0 end function draw_player() spr(p.sprite,p.x*8,p.y*8) end function move_player() newx=p.x newy=p.y
if (btnp(⬅️)) newx-=1 if (btnp(➡️)) newx+=1 if (btnp(⬆️)) newy-=1 if (btnp(⬇️)) newy+=1
if(can_move(newx,newy)) then p.x=mid(0,newx,127) p.y=mid(0,newx,63) else sfx(5) end end
I have looked at the cheat sheets and rewatched this video 3 times and my character still doesn't move my code: -- game loop function _init() map_setup() make_player() end function _uptdate() move_player() end function _draw() cls() draw_map() draw_player() end -- map code function map_setup() wall=0 key=1 door=2 anim1=3 anim2=4 lose=6 win=7 end function draw_map() map(0,0,0,0,128,64) end function is_tile(tile_type,x,y) tile=mget(x,y) has_flag=fget(tile,tyle_type) return has_flag end function can_move(x,y) return not is_tile(wall,x,y) end --playercode function make_player() p={} p.x=10 p.y=10 p.sprite=5 p.keys=0 end function draw_player() spr(p.sprite,p.x*8,p.y*8) end function move_player() newx=p.x newy=p.y if(btnp(⬅)) newx-=1 if(btnp(➡)) newx+=1 if(btnp(⬆)) newy-=1 if(btnp(⬇)) newy+=1
if (can_move(newx,newy)) then p.x=mid(0,newx,127) p.y=mid(0,newy,63) else sfx(0) end end does anyone know how to fix this?
I love how he actually explains things as opposed to most coding tutorials. It makes it easy to actually understand what's happening rather than just copying from the video.
This one was tricky, I've had to come back to it to check my understanding again. Thank you. I hope to be able to make a version from memory (without checking these tutorials) soon :)
Thank you for this series!! Collisions have been driving me crazy!
This is the point my brain starts to melt. I really need to study this.
When i follow this code my character can walk through the sprites with the flag on it and the sound plays.
So I've typed the functions for Tiles MGET, FGET and movement, however my player sprite is not being able to move past floor tiles after a certain point of the map. Some wall tiles work and some dont.
would you happen to know why? cant seem to find an answer
Mine just won’t move.
my character can move but collisions/sfx isnt working. if anyone knows why please tell me.
for me it was this function, here is the correct version
function is_tile(tile_type,x,y)
How do I fix this error it keeps coming each time I press Control+r:
Runtime error line 25 tab 1
Return not is_tile(wall,x,y)
Attempted call global “is_tile”
(A nil value)
In can_move line 25 (tab 1)
In move_player line 24 (tab 2)
In _update line 9 (tab 0)
At line 0 (tab 0)
I don’t know what to do I am stuck and this is my first time using pico 8
Someone help
@@Sniper_Fam101 did you ever get this figured out? I am getting the same error and can't figure out why
@@gamequestgb maybe that is an old code so it doesn’t work today
when ever i do ctrl+r to run it takes me to the help menu. help me please
Supersuds playz mine just started doing that.
Edit: you have to press ctrl s to save first.
Save by pressing CTRL+S and THEN press CTRL+R.
Check if your functions in the game loop _init, _update, and _draw have underscores before them. Then try to run it.
help!:it gives me an error!
Sorry, I have another problem. Here's my code for the movement options, it says that i'm calling a nil value again in the update function.
FOR TAB 2:
function move_player()
newx=p.x
newy=p.y
if (btnp(➡️)) newx-=1
if (btnp(⬅️)) newx+=1
if (btnp(⬆️)) newy-=1
if (btnp(⬇️)) newy+=1
if (canmove(newx,newy)) then
p.x=mid(0,newx,127)
p.y=mid(0,newy,63)
else
sfx(0)
end
end
FOR TAB 1:
function is_tile(x,y,tile_type)
tile=mget(x,y)
has_flag=fget(tile,tile_type)
return has_flag
end
function can_move(x,y)
return not is_tile(x,y,wall)
end
Thanks again!
Never mind, I figured out the problem, it was basically just me typing incorrectly and forgetting basic things. Thanks for creating this tutorial series by the way, it's helped me out a lot
@@cheshirecreeper3743 Glad you caught the error! My only advice would be to try not to get too frustrated with problems like that. Those little errors are more common than you might think. I have been programming for 30 years and I make those kinds of mistakes *all the time*. Literally. Usually the error message will point you to the right line, but not always. But 9 times out of 10 it's a little error like that. I'm happy to help any time you need it.
That's all for today teach. see ya tomorrow!
Thanks! :D
My little character is alive! But can't can't go left?
Double check when you're listening for the button presses in the move_player() function that you have newx-=1 for the left button and newx+=1 for the right button.
i dont know why, but my character doesnt move like that, its moves "Diagonaly", What am I doing wrong?
the code:
--player code
function make_player()
p={}
p.x=3
p.y=2
p.sprite=1
p.keys=0
end
function draw_player()
spr(p.sprite,p.x*8,p.y*8)
end
function move_player()
newx=p.x
newy=p.y
if (btnp(⬅️)) newx-=1
if (btnp(➡️)) newx+=1
if (btnp(⬆️)) newy-=1
if (btnp(⬇️)) newy+=1
if(can_move(newx,newy)) then
p.x=mid(0,newx,127)
p.y=mid(0,newx,63)
else
sfx(5)
end
end
I have the same promblem, did u solve it, if so can u tell me why it moves like that
could you maybe send your map code?
@@fireball4285 i fixed my problem
@@Ingb3rg what did u do
@@Ingb3rg wait how I have the same problem
I have looked at the cheat sheets and rewatched this video 3 times and my character still doesn't move
my code:
-- game loop
function _init()
map_setup()
make_player()
end
function _uptdate()
move_player()
end
function _draw()
cls()
draw_map()
draw_player()
end
-- map code
function map_setup()
wall=0
key=1
door=2
anim1=3
anim2=4
lose=6
win=7
end
function draw_map()
map(0,0,0,0,128,64)
end
function is_tile(tile_type,x,y)
tile=mget(x,y)
has_flag=fget(tile,tyle_type)
return has_flag
end
function can_move(x,y)
return not is_tile(wall,x,y)
end
--playercode
function make_player()
p={}
p.x=10
p.y=10
p.sprite=5
p.keys=0
end
function draw_player()
spr(p.sprite,p.x*8,p.y*8)
end
function move_player()
newx=p.x
newy=p.y
if(btnp(⬅)) newx-=1
if(btnp(➡)) newx+=1
if(btnp(⬆)) newy-=1
if(btnp(⬇)) newy+=1
if (can_move(newx,newy)) then
p.x=mid(0,newx,127)
p.y=mid(0,newy,63)
else
sfx(0)
end
end
does anyone know how to fix this?
I noticed one tiny typo! You have _uptdate() instead of _update() Hopefully that fixes it! If not, let me know and I'll be happy to help.
@@DylanBennett OOHHHHHHHHH
ta travado de lança meu boneco, to com dificuldade...
Vish:/