In more of a attempt to learn Pico 8 simply from the manual I have created a enemy that cases the player.
There is nothing very exciting to this as it is a test of the logic. Essentially the enemy looks to see where the player x and y is. it then minuses or adds 1 to its own location depending on if it is > or < the target location on the x and y.



Who says that smashing your head against a brick wall for a while doesn't yield results.
So in my attempt to go teh old school I decided to see how well I could implement some hit detection. Using all code with hard coded images.
First issue. The centre point is literal.
Yeah this means that trying to keep the ball in play field will always result in some overhang. Which doesn't look good.
Enter arrays!
and the second issue. They are a twat to work with. In a good kind of way.
I ended up making some markers to make a kind of hit point. Once this point goes past the screen bounds it keeps the ball in the field.
as the markers leave the field it forces the middle of the ball to a neutral area in the field close to the edge. Giving the impression the ball is staying put.
Anyway. Have a play and look at the code. I have tried to annotate as much as possible and left debugging info on the screen.



This really does feel like the old days. Where you would turn on a BBC Micro, C64 or MS-DOS computer and then get stuck in.
When I saw the program does peeks and pokes I nearly wept. Out of nostalgic joy and flashbacks to getting the C64 to bloody do what I wanted it to lol.
I love the little pixel editor. Reminds me of SEUCK in the way it works. And the Wave editor is like something I used on the Amiga.
Bravo!
Could be me been tired. But I don't get why my character is falling through the map.
I thought I had done some basic collision detection, after following some tutorials. However it doesn't seem to work and my character simply falls straight through the map.
--player variables p1= { --initial sprite start --point and velocities x=64, y=24, vx=0, vy=0, isgrounded=false, grav=0.2, } function _update() --left and right movement p1.dx=0 if btn(0) then --left p1.dx=-2 end if btn(1) then --right p1.dx+=2 end p1.x+=p1.dx --gravity p1.vy+=p1.grav p1.y+=p1.vy local v=mget((p1.x+4)/8,(p1.y+8)/8) p1.isgrounded=false if p1.vy>=0 then --look for a solid tile if fget(v,0) then --place p1 on top of tile p1.y = flr((p1.y)/8)*8 --halt velocity p1.dy = 0 --allow jumping again p1.isgrounded=true end end end function _draw() cls() map(0,0,0,0,128,128) spr(48,p1.x,p1.y) end |



