From bb7c3e0250d2a6d0e2d48e621593646845fbd53f Mon Sep 17 00:00:00 2001 From: kdx Date: Sat, 2 Mar 2024 07:09:30 +0100 Subject: fix tabulations --- celex.p8 | 322 +++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 161 insertions(+), 161 deletions(-) diff --git a/celex.p8 b/celex.p8 index 6ca274d..d87d16e 100644 --- a/celex.p8 +++ b/celex.p8 @@ -35,7 +35,7 @@ k_dash=5 ----------------- function _init() - menuitem_screenshake() + menuitem_screenshake() title_screen() end @@ -125,8 +125,8 @@ player = -- spikes collide if spikes_at(this.x+this.hitbox.x,this.y+this.hitbox.y,this.hitbox.w,this.hitbox.h,this.spd.x,this.spd.y) then - kill_player(this) end - + kill_player(this) end + -- bottom death if this.y>128 then kill_player(this) end @@ -136,7 +136,7 @@ player = -- smoke particles if on_ground and not this.was_on_ground then - init_object(smoke,this.x,this.y+4) + init_object(smoke,this.x,this.y+4) end local jump = btn(k_jump) and not this.p_jump @@ -144,7 +144,7 @@ player = if (jump) then this.jbuffer=4 elseif this.jbuffer>0 then - this.jbuffer-=1 + this.jbuffer-=1 end local dash = btn(k_dash) and not this.p_dash @@ -153,20 +153,20 @@ player = if on_ground then this.grace=6 if this.djump 0 then - this.grace-=1 + this.grace-=1 end this.dash_effect_time -=1 - if this.dash_time > 0 then - init_object(smoke,this.x,this.y) - this.dash_time-=1 - this.spd.x=appr(this.spd.x,this.dash_target.x,this.dash_accel.x) - this.spd.y=appr(this.spd.y,this.dash_target.y,this.dash_accel.y) - else + if this.dash_time > 0 then + init_object(smoke,this.x,this.y) + this.dash_time-=1 + this.spd.x=appr(this.spd.x,this.dash_target.x,this.dash_accel.x) + this.spd.y=appr(this.spd.y,this.dash_target.y,this.dash_accel.y) + else -- move local maxrun=1 @@ -183,7 +183,7 @@ player = end if abs(this.spd.x) > maxrun then - this.spd.x=appr(this.spd.x,sign(this.spd.x)*maxrun,deccel) + this.spd.x=appr(this.spd.x,sign(this.spd.x)*maxrun,deccel) else this.spd.x=appr(this.spd.x,input*maxrun,accel) end @@ -197,15 +197,15 @@ player = local maxfall=2 local gravity=0.21 - if abs(this.spd.y) <= 0.15 then - gravity*=0.5 + if abs(this.spd.y) <= 0.15 then + gravity*=0.5 end -- wall slide if input!=0 and this.is_solid(input,0) and not this.is_ice(input,0) then - maxfall=0.4 - if rnd(10)<2 then - init_object(smoke,this.x+input*6,this.y) + maxfall=0.4 + if rnd(10)<2 then + init_object(smoke,this.x+input*6,this.y) end end @@ -215,23 +215,23 @@ player = -- jump if this.jbuffer>0 then - if this.grace>0 then - -- normal jump - psfx(1) - this.jbuffer=0 - this.grace=0 + if this.grace>0 then + -- normal jump + psfx(1) + this.jbuffer=0 + this.grace=0 this.spd.y=-2 init_object(smoke,this.x,this.y+4) else -- wall jump local wall_dir=(this.is_solid(-3,0) and -1 or this.is_solid(3,0) and 1 or 0) if wall_dir!=0 then - psfx(2) - this.jbuffer=0 - this.spd.y=-2 - this.spd.x=-wall_dir*(maxrun+1) - if not this.is_ice(wall_dir*3,0) then - init_object(smoke,this.x+wall_dir*6,this.y) + psfx(2) + this.jbuffer=0 + this.spd.y=-2 + this.spd.x=-wall_dir*(maxrun+1) + if not this.is_ice(wall_dir*3,0) then + init_object(smoke,this.x+wall_dir*6,this.y) end end end @@ -242,49 +242,49 @@ player = local d_half=d_full*0.70710678118 if this.djump>0 and dash then - init_object(smoke,this.x,this.y) - this.djump-=1 - this.dash_time=4 - has_dashed=true - this.dash_effect_time=10 - local v_input=(btn(k_up) and -1 or (btn(k_down) and 1 or 0)) - if input!=0 then - if v_input!=0 then - this.spd.x=input*d_half - this.spd.y=v_input*d_half - else - this.spd.x=input*d_full - this.spd.y=0 - end - elseif v_input!=0 then - this.spd.x=0 - this.spd.y=v_input*d_full - else - this.spd.x=(this.flip.x and -1 or 1) - this.spd.y=0 - end - - psfx(3) - freeze=0 - shake=6 - this.dash_target.x=2*sign(this.spd.x) - this.dash_target.y=2*sign(this.spd.y) - this.dash_accel.x=1.5 - this.dash_accel.y=1.5 - - if this.spd.y<0 then - this.dash_target.y*=.75 - end - - if this.spd.y!=0 then - this.dash_accel.x*=0.70710678118 - end - if this.spd.x!=0 then - this.dash_accel.y*=0.70710678118 - end + init_object(smoke,this.x,this.y) + this.djump-=1 + this.dash_time=4 + has_dashed=true + this.dash_effect_time=10 + local v_input=(btn(k_up) and -1 or (btn(k_down) and 1 or 0)) + if input!=0 then + if v_input!=0 then + this.spd.x=input*d_half + this.spd.y=v_input*d_half + else + this.spd.x=input*d_full + this.spd.y=0 + end + elseif v_input!=0 then + this.spd.x=0 + this.spd.y=v_input*d_full + else + this.spd.x=(this.flip.x and -1 or 1) + this.spd.y=0 + end + + psfx(3) + freeze=0 + shake=6 + this.dash_target.x=2*sign(this.spd.x) + this.dash_target.y=2*sign(this.spd.y) + this.dash_accel.x=1.5 + this.dash_accel.y=1.5 + + if this.spd.y<0 then + this.dash_target.y*=.75 + end + + if this.spd.y!=0 then + this.dash_accel.x*=0.70710678118 + end + if this.spd.x!=0 then + this.dash_accel.y*=0.70710678118 + end elseif dash and this.djump<=0 then - psfx(9) - init_object(smoke,this.x,this.y) + psfx(9) + init_object(smoke,this.x,this.y) end end @@ -331,9 +331,9 @@ player = } psfx=function(num) - if sfx_timer<=0 then - sfx(num) - end + if sfx_timer<=0 then + sfx(num) + end end create_hair=function(obj) @@ -364,7 +364,7 @@ end player_spawn = { tile=1, init=function(this) - sfx(4) + sfx(4) this.spr=3 this.target= {x=this.x,y=this.y} this.y=128 @@ -493,8 +493,8 @@ balloon = { elseif this.timer>0 then this.timer-=1 else - psfx(7) - init_object(smoke,this.x,this.y) + psfx(7) + init_object(smoke,this.x,this.y) this.spr=22 end end, @@ -551,8 +551,8 @@ fall_floor = { add(types,fall_floor) function break_fall_floor(obj) - if obj.state==0 then - psfx(15) + if obj.state==0 then + psfx(15) obj.state=1 obj.delay=15--how long until it falls init_object(smoke,obj.x,obj.y) @@ -590,9 +590,9 @@ fruit={ this.off=0 end, update=function(this) - local hit=this.collide(player,0,0) + local hit=this.collide(player,0,0) if hit~=nil then - hit.djump=max_djump + hit.djump=max_djump sfx_timer=20 sfx(13) got_fruit[1+level_index()] = true @@ -618,13 +618,13 @@ fly_fruit={ update=function(this) --fly away if this.fly then - if this.sfx_delay>0 then - this.sfx_delay-=1 - if this.sfx_delay<=0 then - sfx_timer=20 - sfx(14) - end - end + if this.sfx_delay>0 then + this.sfx_delay-=1 + if this.sfx_delay<=0 then + sfx_timer=20 + sfx(14) + end + end this.spd.y=appr(this.spd.y,-3.5,0.25) if this.y<-16 then destroy_object(this) @@ -640,7 +640,7 @@ fly_fruit={ -- collect local hit=this.collide(player,0,0) if hit~=nil then - hit.djump=max_djump + hit.djump=max_djump sfx_timer=20 sfx(13) got_fruit[1+level_index()] = true @@ -750,8 +750,8 @@ chest={ this.timer-=1 this.x=this.start-1+rnd(3) if this.timer<=0 then - sfx_timer=20 - sfx(16) + sfx_timer=20 + sfx(16) init_object(fruit,this.x,this.y-4) destroy_object(this) end @@ -792,10 +792,10 @@ message={ this.text="-- celeste mountain --#this memorial to those# perished on the climb" if this.check(player,4,0) then if this.index<#this.text then - this.index+=0.5 + this.index+=0.5 if this.index>=this.last+1 then - this.last+=1 - sfx(35) + this.last+=1 + sfx(35) end end this.off={x=8,y=96} @@ -842,8 +842,8 @@ big_chest={ spr(97,this.x+8,this.y) elseif this.state==1 then this.timer-=1 - shake=5 - flash_bg=true + shake=5 + flash_bg=true if this.timer<=45 and count(this.particles)<50 then add(this.particles,{ x=1+rnd(14), @@ -881,7 +881,7 @@ orb={ this.spd.y=appr(this.spd.y,0,0.5) local hit=this.collide(player,0,0) if this.spd.y==0 and hit~=nil then - music_timer=45 + music_timer=45 sfx(51) freeze=10 shake=10 @@ -921,7 +921,7 @@ flag = { print("deaths:"..deaths,48,24,7) elseif this.check(player,0,0) then sfx(55) - sfx_timer=30 + sfx_timer=30 this.show=true end end @@ -931,7 +931,7 @@ add(types,flag) room_title = { init=function(this) this.delay=5 - end, + end, draw=function(this) this.delay-=1 if this.delay<-30 then @@ -983,8 +983,8 @@ function init_object(type,x,y) return true end return solid_at(obj.x+obj.hitbox.x+ox,obj.y+obj.hitbox.y+oy,obj.hitbox.w,obj.hitbox.h) - or obj.check(fall_floor,ox,oy) - or obj.check(fake_wall,ox,oy) + or obj.check(fall_floor,ox,oy) + or obj.check(fake_wall,ox,oy) end obj.is_ice=function(ox,oy) @@ -1013,7 +1013,7 @@ function init_object(type,x,y) obj.move=function(ox,oy) local amount -- [x] get move amount - obj.rem.x += ox + obj.rem.x += ox amount = flr(obj.rem.x + 0.5) obj.rem.x -= amount obj.move_x(amount,0) @@ -1046,7 +1046,7 @@ function init_object(type,x,y) if obj.solids then local step = sign(amount) for i=0,abs(amount) do - if not obj.is_solid(0,step) then + if not obj.is_solid(0,step) then obj.y += step else obj.spd.y = 0 @@ -1101,15 +1101,15 @@ function restart_room() end function next_room() - if room.x==2 and room.y==1 then - music(30,500,7) - elseif room.x==3 and room.y==1 then - music(20,500,7) - elseif room.x==4 and room.y==2 then - music(30,500,7) - elseif room.x==5 and room.y==3 then - music(30,500,7) - end + if room.x==2 and room.y==1 then + music(30,500,7) + elseif room.x==3 and room.y==1 then + music(20,500,7) + elseif room.x==4 and room.y==2 then + music(30,500,7) + elseif room.x==5 and room.y==3 then + music(30,500,7) + end if room.x==7 then load_room(0,room.y+1) @@ -1166,14 +1166,14 @@ function _update() end if music_timer>0 then - music_timer-=1 - if music_timer<=0 then - music(10,0,7) - end + music_timer-=1 + if music_timer<=0 then + music(10,0,7) + end end if sfx_timer>0 then - sfx_timer-=1 + sfx_timer-=1 end -- cancel if freeze @@ -1380,9 +1380,9 @@ function clamp(val,a,b) end function appr(val,target,amount) - return val > target - and max(val - amount, target) - or min(val + amount, target) + return val > target + and max(val - amount, target) + or min(val + amount, target) end function sign(v) @@ -1395,73 +1395,73 @@ function maybe() end function solid_at(x,y,w,h) - return tile_flag_at(x,y,w,h,0) + return tile_flag_at(x,y,w,h,0) end function ice_at(x,y,w,h) - return tile_flag_at(x,y,w,h,4) + return tile_flag_at(x,y,w,h,4) end function tile_flag_at(x,y,w,h,flag) - for i=max(0,flr(x/8)),min(15,(x+w-1)/8) do - for j=max(0,flr(y/8)),min(15,(y+h-1)/8) do - if fget(tile_at(i,j),flag) then - return true - end - end - end + for i=max(0,flr(x/8)),min(15,(x+w-1)/8) do + for j=max(0,flr(y/8)),min(15,(y+h-1)/8) do + if fget(tile_at(i,j),flag) then + return true + end + end + end return false end function tile_at(x,y) - return mget(room.x * 16 + x, room.y * 16 + y) + return mget(room.x * 16 + x, room.y * 16 + y) end function spikes_at(x,y,w,h,xspd,yspd) - for i=max(0,flr(x/8)),min(15,(x+w-1)/8) do - for j=max(0,flr(y/8)),min(15,(y+h-1)/8) do - local tile=tile_at(i,j) - if tile==17 and ((y+h-1)%8>=6 or y+h==j*8+8) and yspd>=0 then - return true - elseif tile==27 and y%8<=2 and yspd<=0 then - return true - elseif tile==43 and x%8<=2 and xspd<=0 then - return true - elseif tile==59 and ((x+w-1)%8>=6 or x+w==i*8+8) and xspd>=0 then - return true - end - end - end + for i=max(0,flr(x/8)),min(15,(x+w-1)/8) do + for j=max(0,flr(y/8)),min(15,(y+h-1)/8) do + local tile=tile_at(i,j) + if tile==17 and ((y+h-1)%8>=6 or y+h==j*8+8) and yspd>=0 then + return true + elseif tile==27 and y%8<=2 and yspd<=0 then + return true + elseif tile==43 and x%8<=2 and xspd<=0 then + return true + elseif tile==59 and ((x+w-1)%8>=6 or x+w==i*8+8) and xspd>=0 then + return true + end + end + end return false end -->8 -- centered print function cprint(txt,x,y,c,c2) - fprint(txt,x-#txt*2,y,c,c2) + fprint(txt,x-#txt*2,y,c,c2) end -- fancy print function fprint(txt,x,y,c,c2) - if c2 then - print(txt,x-1,y,c2) - print(txt,x+1,y,c2) - print(txt,x,y-1,c2) - print(txt,x,y+1,c2) - print(txt,x-1,y-1,c2) - print(txt,x-1,y+1,c2) - print(txt,x+1,y-1,c2) - print(txt,x+1,y+1,c2) - end - print(txt,x,y,c) + if c2 then + print(txt,x-1,y,c2) + print(txt,x+1,y,c2) + print(txt,x,y-1,c2) + print(txt,x,y+1,c2) + print(txt,x-1,y-1,c2) + print(txt,x-1,y+1,c2) + print(txt,x+1,y-1,c2) + print(txt,x+1,y+1,c2) + end + print(txt,x,y,c) end -->8 function menuitem_screenshake() - menuitem(1,"screenshake "..(screenshake and"on"or"off"),menu_screenshake) + menuitem(1,"screenshake "..(screenshake and"on"or"off"),menu_screenshake) end function menu_screenshake() - screenshake=not screenshake - menuitem_screenshake() + screenshake=not screenshake + menuitem_screenshake() end __gfx__ 000000000000000000000000088888800000000000000000000000000000000000aaaaa0000aaa000000a0000007707770077700000060000000600000060000 -- cgit v1.2.3