I'm new to Pico 8
I've been developing this simple game as a first project where you play as "GeK" a simple character that has animations when walking around, however i've found that when moving diagonally it makes the character faster than usual. This issue is very confusing to me and I know it has something to do with the Pythagorean theorem, and I need something called a "movement vector" My code is simple as it has a variable known as speed that is set to 1 and is used when pressing a direction to move by 1 pixel. The character also has a hat and tail that follows it and is supposed to be locked on at all times.
I'd really appreciate it if anyone knows the solution to my problem.
Here's my code if it helps with anything:
function _init() -- setting up variables ismoving = false mainxposition = 63 mainyposition = 63 hatxoffset = 0 hatyoffset = -8 tailxoffset = 8 tailyoffset = 0 walkcycle = 1 animtime = 0 animspeed = 3 tailanim = 2 directionx = "left" directiony = "up" hatanim=18 uptailx=0 uptaily=0 uptailanim=0 uptailxoffset=0 uptailyoffset=8 upand=false downand=false speed=1 end function _update() -- player movement ismoving = false if btn(➡️) or btn(⬅️) then uptailanim=0 ismoving = true animtime += 1 if animtime > animspeed and directionx=="right" and not upand then animtime = 0 walkcycle = walkcycle == 3 and 4 or 3 end if animtime > animspeed and directionx=="right" and not upand then animtime = 0 walkcycle = walkcycle == 3 and 4 or 3 end if animtime > animspeed and directionx=="left" and not upand then animtime = 0 walkcycle = walkcycle == 19 and 20 or 19 end end if btn(⬆️) or btn(⬇️) then ismoving = true tailanim=0 uptailanim=37 animtime += 1 if animtime > animspeed and directiony=="up" then animtime = 0 walkcycle = walkcycle == 35 and 36 or 35 end if animtime > animspeed and directiony=="down" then animtime = 0 walkcycle = walkcycle == 51 and 52 or 51 end end if btn(➡️) then mx=1 hatanim=34 directionx = "right" tailanim = 5 mainxposition += speed end if btn(⬅️) then mx=-1 hatanim=18 directionx = "left" tailanim = 2 mainxposition -= speed end if btn(⬆️) then my=-1 directiony="up" mainyposition -= speed if directionx=="right" then hatanim=34 end if directionx=="left" then hatanim=18 end end if btn(⬇️) then my=1 directiony="down" mainyposition += speed uptailanim=0 end --talk-- if btn(❎) then walkcycle=17 end if btn(❎) and directiony=="up" then walkcycle=49 end --update hat position-- hatxposition = mainxposition + hatxoffset hatyposition = mainyposition + hatyoffset -- adjust tail position based on direction-- if directionx == "left" then tailxposition = mainxposition + tailxoffset else tailxposition = mainxposition - tailxoffset end tailyposition = mainyposition + tailyoffset if directiony == "up" then uptailx= mainxposition + uptailxoffset uptaily= mainyposition + uptailyoffset else uptailx = mainxposition - uptailxoffset end tailyposition = mainyposition + tailyoffset --checking moving for animation-- if not ismoving and not btn(❎) then walkcycle = 1 upand=false end if btn(⬇️) and directionx=="right" then hatanim=22 end if btn(⬇️) and directionx=="left" then hatanim=21 end if btn(⬆️) and btn (➡️) or btn(⬆️) and btn(⬅️) then tailanim=0 upand=true else upand=false end if btn(⬇️) and btn (➡️) or btn(⬇️) and btn(⬅️) then tailanim=0 downand=true else downand=false end if btn(⬆️) and btn (➡️) and ismoving then uptailanim=38 end if btn(⬆️) and btn (⬅️) and ismoving then uptailanim=37 end if not ismoving and not btn(❎) and uptailanim==37 then walkcycle = 33 end end function _draw() -- draw sprites-- cls() spr(walkcycle, mainxposition, mainyposition) spr(hatanim, hatxposition, hatyposition) spr(tailanim, tailxposition, tailyposition) spr(uptailanim,uptailx,uptaily) end |
P#145310 2024-04-01 01:19
Hi! I am new here
I just barely bought Pico 8 and used some tutorials online to make this simple animated "GeK"
If anyone has any tips or just criticism for beginners like me, I'd very much appreciate it.
(I have had experience with html and JavaScript before)
0.3 finally released
Controls are simple: Arrows move GeK and X makes him "speak"
This is 0.2
Here's the version I started with (Also known as 0.1)
P#145210 2024-03-31 04:34 ( Edited 2024-04-02 00:01)
Hello I am GeK and I am wondering if anyone could share me some good games since I am new here and I dont how to find some good games so this is the only way I know of Thanks!
P#104929 2022-01-12 23:20