Log In  
Follow
rupees

B E G I N N E R

[ :: Read More :: ]

hello world.
I think I'm missing something in the custom function realm when it comes to using variables as arguments. I'm trying to pass in a variable that defines one of 6 beams to a function so I can use it for all of the beams but it does not seem to be working and I think I'm trying to do something that might not be allowed in Pico-8. For example I have a custom function to light up this beam and it works great:

..but I need to reuse this to do something similar for 5 more of these beams. I'd like to create a reusable function around the following as I am repeating code:

function beam_2()
if mg(35) and p.x<500
then
pal(5,7)
spr(35,384,328) sfx(0)
b2_charge=true
else b2_charge=false pal()
end
if b2_go==true then
pal(5,7)
spr(35,384,328)
pal()
end
end

I thought I could get away with using something like the below bm_chg function in place of the beam_2 function but it does not seem to be passing the b2_charge variable when I input it for chg_var.

function bm_chg(sp,sx,sy,sc,chg_var,go_var)

if mg(sp) and p.x<96 then

   pal(sc,7)  
   spr(sp,sx,sy) sfx(0)
   chg_var=true   

else chg_var=false pal()

end

if go_var==true then
pal(sc,7)
spr(sp,sx,sy)
pal()
end

end

I was unable to find any documentation of exactly how this works in the manual and any help would be greatly appreciated.

P#141240 2024-02-07 03:49

[ :: Read More :: ]

I'm hoping someone out there can help me solve the ever increasing speed of my bird animation. The goal is to have the ability to put these bird sprites (spr 39 is the static resting bird sprite) all over the map and as the player gets close to them they are disturbed and fly away. A counter ("birds") counts them and this counter is used to alter states later in the game. Everything is working except that every bird that is disturbed flaps it's wings faster than the previous bird. Any attempt to reset this just results in the bird not animating at all and floating away motionless which is kind of comical. :P

My update and draw code for these bad bois are below. Any ideas as to how I could get them to fly away at the same animation speed regardless of how many have been disturbed? Newish to coding in general here so I'm probably going about this the wrong way. FYI, sprite 39 and 19 are both static versions of the bird depending on the background they sit in front of.

--birds--

function u_bird()
-- btimer=0

for y = flr(p.y/8)-1,flr(p.y/8)+1 do

for x = flr(p.x/8)-1,flr(p.x/8)+1 do

        if mget(x,y)==39 or mget(x,y)==19 then
            add(fly,{
                ex=x*8,
                ey=y*8,
                sp=39,            
            })
            if mget(x,y)==39 then
            mset(x,y,59) 
            elseif mget(x,y)==19 then
            mset(x,y,38)
            end

            birds+=1
        end                              
 end
end 

for e in all(fly) do

e.ey-=.5
e.ex+=.2
e.sp=birdsp

    if birdsp<43.9 and birdsp>=40.1 then                  
                birdsp+=.1                  
    else 
            birdsp=40.1                          
    end       

end
end

function d_bird()

for e in all(fly) do
spr(birdsp,e.ex,e.ey)
end

end

P#138625 2023-12-13 02:40

[ :: Read More :: ]

Cart #kudojowipa-0 | 2023-08-08 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
3

I'm new to PICO-8 here folks but absolutely hooked! I'm having a problem with my player shaking during movement as well as getting caught on my flagged sprites that the player collides with. I know some basics and have compiled this code by watching tutorials and scanning forums for code snippets but I think I am mixing some things that don't play well. I am really going for a smooth player movement vibe so I just added some acceleration rather than an abrupt "p.x+=1" movement style. It doesn't appear to show in my GIF but the player shakes violently during gameplay. Any ideas as to what could be causing this would be greatly appreciated!

P#132850 2023-08-08 01:13