toomgis jumping
This commit is contained in:
		
							parent
							
								
									8358a36cc0
								
							
						
					
					
						commit
						bdad4ffa32
					
				
					 1 changed files with 39 additions and 51 deletions
				
			
		
							
								
								
									
										86
									
								
								toomgis.p8
									
									
									
									
									
								
							
							
						
						
									
										86
									
								
								toomgis.p8
									
									
									
									
									
								
							|  | @ -10,25 +10,11 @@ end | ||||||
| 
 | 
 | ||||||
| function _update() | function _update() | ||||||
| 	--ampm_upd() | 	--ampm_upd() | ||||||
| 	--toomgis_upd() | 	toomgis_upd() | ||||||
| 	--level_draw() | 	--level_draw() | ||||||
| 	level_upd() | 	level_upd() | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| function test_draw() |  | ||||||
| 	cls() |  | ||||||
| 	sprm(0, 20, 20, 1, 2) |  | ||||||
| 	sprm(32, 20, 32, 1, 2) |  | ||||||
| 	 |  | ||||||
| 	sprm(44, 80, 80, 1, 2) |  | ||||||
| 	 |  | ||||||
| 	sprm(0, 50, 100, 1, 2) |  | ||||||
| 	sprm(32, 50, 112, 1, 2) |  | ||||||
| 	spr(35, 50, 112, 2, 2) |  | ||||||
| 	 |  | ||||||
| 	sprm(15, 100, 10, 1, 4)  |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| function sprm(n, x, y, w, h) | function sprm(n, x, y, w, h) | ||||||
| 	-- mirrored sprite draw | 	-- mirrored sprite draw | ||||||
| 	spr(n, x, y, w, h) | 	spr(n, x, y, w, h) | ||||||
|  | @ -91,14 +77,25 @@ end | ||||||
| -->8 | -->8 | ||||||
| -- toomgis | -- toomgis | ||||||
| 
 | 
 | ||||||
| tspeed = -0.01 |  | ||||||
| tangle = 0 | tangle = 0 | ||||||
| tbody = { | tbody = { | ||||||
| } | } | ||||||
|  | pieces = 1 | ||||||
|  | MAX_PIECES = 200 | ||||||
|  | px = 0 | ||||||
|  | py = 0 | ||||||
|  | vx = 0 | ||||||
|  | vy = 0 | ||||||
|  | yacc = 0 | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| function add2body(n) | function add2body(n) | ||||||
| 	add(tbody, {n=n, r=rnd(20)+5, | 	if pieces < MAX_PIECES then | ||||||
| 	 off=rnd(4)}) | 		pieces += 1 | ||||||
|  | 		-- center hole + variance + grow outwards | ||||||
|  | 		local r = 5 + rnd(5) + (pieces / MAX_PIECES) * 25 | ||||||
|  | 		add(tbody, {n=n, r=r, off=rnd(4)}) | ||||||
|  | 	end | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| function full() | function full() | ||||||
|  | @ -124,7 +121,11 @@ function toomgis_draw(x, y) | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| function toomgis_upd() | function toomgis_upd() | ||||||
| 	tangle += tspeed | 	tangle += vx * 0.01 | ||||||
|  | 	px += vx | ||||||
|  | 	py = max(0, py+vy) | ||||||
|  | 	vy += yacc | ||||||
|  | 	printh("vy="..vy.." yacc="..yacc) | ||||||
| end | end | ||||||
| -->8 | -->8 | ||||||
| -- level | -- level | ||||||
|  | @ -142,14 +143,7 @@ levels = { | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| lvl = levels[1] | lvl = levels[1] | ||||||
| zoom = 16 |  | ||||||
| horizon = 64 | horizon = 64 | ||||||
| px = 0 |  | ||||||
| py = 0 |  | ||||||
| vx = 0 |  | ||||||
| vy = 0 |  | ||||||
| yacc = 0 |  | ||||||
| 
 |  | ||||||
| 
 | 
 | ||||||
| function level_draw() | function level_draw() | ||||||
| 
 | 
 | ||||||
|  | @ -159,16 +153,16 @@ function level_draw() | ||||||
| 	 | 	 | ||||||
| 	--map(0, lvl.y, 0, 32, 16, 8) | 	--map(0, lvl.y, 0, 32, 16, 8) | ||||||
| 	-- each level is 3tl/24px | 	-- each level is 3tl/24px | ||||||
|  | 	cls(lvl.sky) | ||||||
|  | 	--- zoom should go from 16 to 2 w/ growth | ||||||
|  | 	local zoom = 16 - (14 * (pieces / MAX_PIECES)) | ||||||
| 	local h=24 * zoom | 	local h=24 * zoom | ||||||
| 	for y=0,h do | 	for y=0,h do | ||||||
| 		tline(0, 128-h+y, 128, 128-h+y, | 		tline(0, 128-h+y, 128, 128-h+y, | ||||||
| 		 0, 2+y/(8*zoom), 1/(8*zoom), 0) | 		(px-20)/(8*zoom), 2+y/(8*zoom), 1/(8*zoom), 0) | ||||||
| 	end | 	end | ||||||
| 	 | 	 | ||||||
| 	toomgis_draw(10, 96-py) | 	toomgis_draw(20, 96-py) | ||||||
| 	 |  | ||||||
| 	-- debug |  | ||||||
| 	print(px..", "..py, 0, 0, 12) |  | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| function level_upd() | function level_upd() | ||||||
|  | @ -180,27 +174,21 @@ function level_upd() | ||||||
| 	end | 	end | ||||||
| 	if vx < 0 then | 	if vx < 0 then | ||||||
| 		vx = 0 | 		vx = 0 | ||||||
| 	elseif vx > 5 then | 	elseif vx > 3 then | ||||||
| 	 vx = 5 | 		vx = 3 | ||||||
| 	end | 	end | ||||||
| 	if btn(❎) and py==0 then | 	if btnp(❎) and py == 0 then | ||||||
| 		yacc = 3 | 		yacc = 10 | ||||||
|  | 	elseif py > 0 then | ||||||
|  | 		yacc = -3 | ||||||
|  | 	elseif py == 0 and yacc < 0 then | ||||||
|  | 		-- on ground | ||||||
|  | 		yacc = 0 | ||||||
|  | 		vy = 0 | ||||||
| 	end | 	end | ||||||
| 
 | 
 | ||||||
| 	px += vx | 	-- make toomgis bigger as he rolls | ||||||
| 	py = max(0, py+vy) | 	add2body(flr(rnd(14)+2)) | ||||||
| 	vy += yacc |  | ||||||
| 	yacc -= 0.3 |  | ||||||
| 	 |  | ||||||
| 		-- debug, zoom ctls |  | ||||||
|   if btn(⬆️) then |  | ||||||
|   	zoom += 0.1 |  | ||||||
|   elseif btn(⬇️) then |  | ||||||
|   	zoom -= 0.1 |  | ||||||
|   end |  | ||||||
|   if zoom < .5 then |  | ||||||
|   	zoom = .5 |  | ||||||
|   end |  | ||||||
| end | end | ||||||
| __gfx__ | __gfx__ | ||||||
| 000022220000000000444400000ee000aaaaaaaa0000000000555500045454000099990000087000000000000cccccc00077700000000a0000ffff0000005555 | 000022220000000000444400000ee000aaaaaaaa0000000000555500045454000099990000087000000000000cccccc00077700000000a0000ffff0000005555 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 James Turk
						James Turk