Hi friends,
I'm struggling to create a simple pendulum motion. I'm just trying to get a pixel to move along an arc and swing back. If I understand correctly, I need an angle variable that oscillates between .25 and .75. Right now, my angle variable ("a") oscillates between 1 and 0. How do I modulate the angle so it bounces between .75 and .25?
x,y=63,63 function _update() a = abs(time()/2 % 2-1) x=x+sin(a) y=y+cos(a) end function _draw() cls() pset(x,y,7) end |




Hello everybody,
I'm trying to implement collision and knock-back(?) for the particles in my game. I've got it sort of working, but--as you can see from the gif above--some particles behave oddly. Some drip down the tiles, others get caught in mid-air.
I was hoping some kind soul could take a look at my code and tell me if there is a better way of going about this. I'm guessing my issue is a result of how I'm checking for collisions. Thanks!
parts = {} function make_px() for i=1,10 do p={} if not p1.left then p.x=p1.x+7 else p.x=p1.x end p.y=p1.y+7 p.c=4 if not p1.left then p.dx=1+rnd(2) else p.dx=-1-rnd(2) end p.dy=rnd(1)-rnd(.5) p.age=rnd(2) add(parts,p) end end function update_px() local g = .05 --check pixels left, right, above, and below. If there is a collision, add knock-back [ [size=16][color=#ffaabb] [ Continue Reading.. ] [/color][/size] ](/bbs/?pid=166778#p) |


I'm a newbie and I'd like to learn procedural generation to add things like dynamic grass and vegetation to my game. I really like how Zep created the swaying trees in the fireflies gif for the 0.2.4 release, so I thought I'd examine his code. But I'm having some trouble parsing it because the function seems to call itself. I'm assuming this is what's called a recursive function.

How does the function know to stop calling itself? I'm guessing the if statement regarding the l variable terminates it but how? I'm confused because, to my mind, logically, there should be an "else" following the if/then to call the function again. What is the point of the return command?
Here is his function for drawing the trees:
function tree(x,y,a,l) if (l<3) then for ii=0,3 do circfill( x+rnd(8)-rnd(8), y+ii, 1,lcol[4-ii]) end return end local x1=x+cos(a)*l local y1=y+sin(a)*l local q=l/8 local col=l>8 and 13 or 0 for xx=-q,q do line(x+xx,y,x1+xx,y1,col) col=0 end local d= ( cos(t()/3+x1/50)+ cos(t()/4+x1/70) )/500 tree(x1,y1,d+a-.04-rnd(0.04),l*(.9-rnd(0.2))) tree(x1,y1,d+a+.04+rnd(0.04),l*(.9-rnd(0.2))) end |
Thanks!



Is there a wise, benevolent soul out there willing to explain to my feeble mind why this alpha effect doesn't seem to work with a scrolling camera? I can't seem to anchor the light circle to the center of my player character.
function _init() px,py=64,64 end function _draw() cls() map() camera(cx,cy) draw_light() --draw alpha effect print("🐱",px,py) --player end function _update() if (btn(0)) px-=1 if (btn(1)) px+=1 if (btn(2)) py-=1 if (btn(3)) py+=1 cx=px-64 --cam cy=py-64 end |
Here is the draw function for the alpha effect:
function draw_light() poke(0x5f54,0x60) pal({2}) --draw a circle for i=-24,24 do x=sqrt(24*24-i*i) sspr(px-x,py+i, x*2,1, (px-x)+cx,(py+cy)+i) end poke(0x5f54,0x00) pal() end |


My second progress update:
I'm trying to implement the ability for my player character to create temporary blocks which can be used as platforms to reach otherwise unreachable areas. The idea is that the bunny player character digs up earth which piles up behind him and then disappears after a few seconds.
- When the player presses the o button while on a ground tile, a 'newblock' is added to a table so that it can be deleted after its set duration. In order to ensure the original map tile is restored after the 'dirt block' disappears, mget is used to grab the original tile sprite as 'oldblock.'
`if btnp(🅾️) and p.landed then
newblock={}
newblock.spr=14


This is my first blog update. I'm feeling a bit defeated. I'm not making meaningful progress any more. The progress I have made is all but entirely owed to tutorials from nerdy teachers and lazy devs. I'm now spending way more of my time trying to find relevant content to learn from than I am actually learning. I've spent hours combing through BBS posts, reddit, youtube, and discord. When I do find discussion that seems relevant to what I want do, it's rare that I am able to parse the code to learn from it. Trying to stay motivated and move forward.
What I have thus far:
-A running, jumping player sprite which I don't understand how to further animate without continuously looping through a cycle of sprites (How do I do a once-and-done animation?)


My first post. I'm beginning this blog to document my progress in pursuing a passion project, the creation of my first game. The existence of Pico-8 and 'mini metroid-vanias' such as Metroid Crimson, The Ascent, and Subsurface have inspired me. I grew up with an NES and my finest childhood memories involved exploring the game worlds of Zelda and Metroid. My goal is to create a game with a focus on exploration and environmental puzzle solving with progression through an ability-gated game world. I lack programming experience and have a general aversion to math. I'm hopeful the community here will share its wisdom if I'm earnest in my attempt to understand conceptually all the code and math and I refrain from making a million requests for information.
My progress so far: With the assistance of a set of super helpful youtube tutorials, I've created a player sprite capable of running and jumping using platformer controls. I've also managed to alter existing camera code to track the player character room by room.

