uncertifiedloaf [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=99018 cant climb on a climbable wall <p>the thing is, this error only happens when I attempt to make a climbable wall.<br /> here's my setup:</p> <p>my collisions page:</p> <p>--collisions</p> <p>function collide_map(obj,aim,flag)<br /> --obj = table needs x,y,w,h<br /> --aim = left,right,up,down</p> <p>local x=obj.x<br /> local y=obj.y<br /> local w=obj.w<br /> local h=obj.h</p> <p>local x1=0 local y1=0<br /> local x2=0 local y2=0</p> <p>if aim==&quot;left&quot; then<br /> x1=x-2 y1=y<br /> x2=x-1 y2=y+h-1</p> <p>elseif aim==&quot;right&quot; then<br /> x1=x+w+2 y1=y<br /> x2=x+w+1 y2=y+h-1</p> <p>elseif aim==&quot;up&quot; then<br /> x1=x+3 y1=y-1<br /> x2=x+w-3 y2=y</p> <p>elseif aim==&quot;down&quot; then<br /> x1=x+2 y1=y+h<br /> x2=x+w-3 y2=y+h<br /> end</p> <p>--player hitbox test<br /> x1r=x1 y1r=y1<br /> x2r=x2 y2r=y2</p> <p>--pixels to tiles<br /> x1/=8 y1/=8<br /> x2/=8 y2/=8</p> <p>if fget(mget(x1,y1), flag)<br /> or fget(mget(x1,y2), flag)<br /> or fget(mget(x2,y1), flag)<br /> or fget(mget(x2,y2), flag) then<br /> return true<br /> else<br /> return false<br /> end</p> <p>end</p> <p>my player page:<br /> --player<br /> function player_update()<br /> --physics<br /> player.dy+=gravity<br /> player.dx*=friction</p> <p>--controls<br /> if btn(⬅️) then<br /> player.dx-=player.acc<br /> player.running=true<br /> player.flp=true<br /> end<br /> if btn(➡️) then<br /> player.dx+=player.acc<br /> player.running=true<br /> player.flp=false<br /> end</p> <p>--slide<br /> if player.running<br /> and not btn(⬅️)<br /> and not btn(➡️)<br /> and not player.falling<br /> and not player.jumping then<br /> player.running=false<br /> player.sliding=true<br /> end</p> <p>--jump<br /> if btnp(❎)<br /> and player.landed then<br /> player.dy-=player.boost<br /> player.landed=false<br /> end</p> <p>--check collision up and down<br /> if player.dy&gt;0 then<br /> player.falling=true<br /> player.landed=false<br /> player.jumping=false</p> <pre><code>player.dy=limit_speed(player.dy,player.max_dy) if collide_map(player,&quot;down&quot;,0) then player.landed=true player.falling=false player.dy=0 player.y-=((player.y+player.h+1)%8)-1 end</code></pre> <p>elseif player.dy&lt;0 then<br /> player.jumping=true<br /> if collide_map(player,&quot;up&quot;,1) then<br /> player.dy=0<br /> end<br /> end</p> <p>--check collision left and right<br /> if player.dx&lt;0 then</p> <pre><code>player.dx=limit_speed(player.dx,player.max_dx) if collide_map(player,&quot;left&quot;,1) then player.dx=0 end</code></pre> <p>elseif player.dx&gt;0 then</p> <pre><code>player.dx=limit_speed(player.dx,player.max_dx) if collide_map(player,&quot;right&quot;,1) then player.dx=0 end</code></pre> <p>end</p> <p>--stop sliding<br /> if player.sliding then<br /> if abs(player.dx)&lt;.2<br /> or player.running then<br /> player.dx=0<br /> player.sliding=false<br /> end<br /> end</p> <p>player.x+=player.dx<br /> player.y+=player.dy</p> <p>--limit player to map<br /> if player.x&lt;map_start then<br /> player.x=map_start<br /> end<br /> if player.x&gt;map_end-player.w then<br /> player.x=map_end-player.w<br /> end<br /> end</p> <p>function player_animate()<br /> if player.jumping then<br /> player.sp=7<br /> elseif player.falling then<br /> player.sp=8<br /> elseif player.sliding then<br /> player.sp=9<br /> elseif player.running then<br /> if time()-player.anim&gt;.07 then<br /> player.anim=time()<br /> player.sp+=1<br /> if player.sp&gt;6 then<br /> player.sp=3<br /> end<br /> end<br /> else --player idle<br /> if time()-player.anim&gt;.3 then<br /> player.anim=time()<br /> player.sp+=1<br /> if player.sp&gt;2 then<br /> player.sp=1<br /> end<br /> end<br /> end<br /> end</p> <p>function limit_speed(num,maximum)<br /> return mid(-maximum,num,maximum)<br /> end</p> <p>--attempting to climb<br /> function player_climbing()<br /> if collide_map(player,&quot;right&quot;,2)<br /> and btn(❎) and btn(⬆️)<br /> then player.y+=500<br /> end<br /> end</p> <p>flag 2 is meant to be climbable walls.<br /> should this not increase my vertical velocity by 5?</p> https://www.lexaloffle.com/bbs/?tid=142662 https://www.lexaloffle.com/bbs/?tid=142662 Mon, 10 Jun 2024 07:22:04 UTC