Log In  

BBS > Community Superblog
All Users | Following | GIFs | Postcarts | Off-site

As far as I know, every variable is returning as nil. That doesn't mean that it is. I cant get far enough into my game to figure out more

I am unsure what i did. I have gone through my code multiple times and i am just done currently. Any help or advice would be greatly appreciated.

[hidden]

-- game loop

function _init()
 gamestart()
	_upd=update_game()
	_drw=draw_game()
end

function _update()
	frm+=1
	_upd()
end

function _draw()
	_drw()
end

function gamestart()
	frm=1
	col=false
----------------
--menus
----------------
	men_main={
		items={"start game","controls"},
		menx=10,
		meny=10,
		curx=2,
		cury=10,
		menoff=7
	}
----------------
--player
----------------
	p={
	sp=1,
	x=48,
	xo=0,
	y=40,
	yo=0,
	w=8,
	h=8,
	ymt=0,
	spd=1,
	flp=false,
	dx=0,
	dy=0,
	--gravity/collision stuff
	hbx1=1,
	hbx2=6,
	hby1=7,
	hby2=1,
	grv=0.2,
	acc=0.5,
	landed=false,
	jumping=false,
	running=false,
	falling=false,
	dashing=false,
	rolling=false,
	attacking=false,
	itemgrab=false,
	--animation (in sprite #)
		frame=0,
		anim_idle=1,
		anim_walk={1,2,3,4},
		anim_jf=5,
		anim_atk={1,4,6},
		anim_dashing=8,
		anim_rolling={9,10,11,9},
		anim_attacking=6,
		anim_itemgrab=7,
	--game stats
		mhp=10,
		chp=10,
		atk=1,
		def=1,
		agi=1.1,--1.1 beacuse fucking math
}
		inv={}
		abilities={}
----------------
--tiles
----------------
	--collision
	t={--x1=l x2=r y1=t y2=b
		wall={x1=4,x2=6,y1=0,y2=7},
		floor={x1=0,x2=7,y1=4,y2=7}
	}
end
-->8
-- updates
function update_game()
--player---------------------
-----------------------------
		p.frame+=1
		if p.frame==5 then
		 p.frame=1
		end
		if (btn(⬅️))	then
			p.dx=-1
			p.flp=true
			p.running=true
		elseif (btn(➡️))	then
			p.dx=1
			p.flp=false
			p.running=true
		else
			p.dx=0
			p.running=false
		end

--collisions & gravity
		local ly=p.y
		p.dy+=p.grv

--check collision left and right
  if p.dx<0 then
    if collide_map(p,"left",0) then
      p.dx=0
    end
  elseif p.dx>0 then
    if collide_map(p,"right",0) then
      p.dx=0
    end
  end

  --jump
  if btnp(⬆️)
  and p.landed then
    p.dy-=2
    p.landed=false
  end

  --check collision up and down
  if p.dy>0 then
    p.falling=true
    p.landed=false
    p.jumping=false

    if collide_map(p,"down",0) then
      p.landed=true
      p.falling=false
      p.dy=0
      p.y-=((p.y+p.h+1)%8)-1
    end
  elseif p.dy<0 then
    p.jumping=true
    if collide_map(p,"up",0) then
      p.dy=0
    end
  end
	p.x+=p.dx
	p.y+=p.dy
--animation
	if p.jumping or p.falling then
		p.sp=p.anim_jf
	elseif p.running then
		if frm%5<=4 then
			p.sp=p.anim_walk[p.frame]
		end 
	elseif p.attacking then
		p.sp=p.anim_attack
	else --player idle
		p.sp=1
	end

end

function update_mm()
	upd_menu(men_main)
end
-->8
-- draws
function draw_game()
	cls()
	map()
	spr(p.sp,p.x,p.y,1,1,p.flp)
	camera(p.x-60,p.y-60)

	print(p.dx,1+p.x-59,1+p.y-59,8)
	print(p.dy,9+p.x-59,1+p.y-59,8)
end

function draw_mm() 
	cls()
	menutext(men_main.items,men_main.menx,men_main.meny,8)
	drw_menucur(men_main)
end

-->8
--functions
function does_tile(flag,x,y) -- bool
	tile=mget(x,y)
	has_flag=fget(tile,flag)
	return has_flag
end

function collide_map(obj,aim,flag)
 --obj = table needs x,y,w,h
 --aim = left,right,up,down

 local x=obj.x  local y=obj.y
 local w=obj.w  local h=obj.h

 local x1=0	 local y1=0
 local x2=0  local y2=0

 if aim=="left" then
   x1=x-1  y1=y
   x2=x    y2=y+h-1

 elseif aim=="right" then
   x1=x+w-1    y1=y
   x2=x+w  y2=y+h-1

 elseif aim=="up" then
   x1=x+2    y1=y-1
   x2=x+w-3  y2=y

 elseif aim=="down" then
   x1=x+2      y1=y+h
   x2=x+w-3    y2=y+h
 end

 --pixels to tiles
 x1/=8    y1/=8
 x2/=8    y2/=8

 if fget(mget(x1,y1), flag)
 or fget(mget(x1,y2), flag)
 or fget(mget(x2,y1), flag)
 or fget(mget(x2,y2), flag) then
   return true
 else
   return false
 end

end

-->8
--menu

function startmenu(menutable)

end

function menutext(menutable,x,y,off)
	for i=1, #menutable do
		print(menutable[i],x,y+menutable.off*i)
	end
end

function drw_menucur(menutable)	
	local x1 = menutable.curx-8
	local y1 = menutable.cury-10
	local x2 = x1+12
	local y2 = y1+6

	rectfill(x1,y1,x2,y2,7)
end

function upd_menu(menutable)
	if btnp(⬆️) then
	 menutable.cury-=7 
	end
	if btnp(⬇️) then
	 menutable.cury+=7
	end
--	if btnp(❎) then menuacc(menutable)
--	if btnp(🅾️) then menuden(menutable)

end

[ Continue Reading.. ]

1 comment


I've been trying for a day to figure this out and I can't. There's barely any information online about this. Although it feels like everyone knows it but me.

My idea is on initialize to run a nested for loop and add any enemies to a list. And in the update move them.
I did this and it worked! But it incremented in grids. There's no actual code of this since I deleted it, but I could easily reprogram it, if someone asks what the block was.

1
5 comments


Cart #pico8incart-0 | 2024-07-18 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2


lol 3 tokens

2
1 comment


Cart #onemillons_jelpis-0 | 2024-07-18 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA


WARRING
is cartidges lag

0 comments


Cart #perfectly_regular_billiards-4 | 2024-07-18 | Embed ▽ | No License
2


This game is a WIP prototype with a few known (but rarely game-breaking) bugs.
Progression is not persisting between sessions here on Lexaloffle, so I updated the game to unlock level select. I recommend trying to beat each level before progressing, but not everybody has time for that!

Concept

Spoiler alert: these billiards are not regular (and they certainly aren't perfect). I wanted to take the game of billiards, which I've always enjoyed both in real life and in video game form, and turn it on it's head a little. As you play through the 25 levels in this prototype, you will encounter more and more... irregularities.

Story

Bill Iards is a perfectly regular person. He is perfectly happy with his perfectly regular life. One day, a man in a suit knocks on his door, bringing news of the passing of his estranged Uncle Whiz. Bill had no recollection of such a relative, but in any case, Uncle Whiz had willed to him one item: a billiards table.

[ Continue Reading.. ]

2
3 comments


Cart #scarecrows-0 | 2024-07-18 | Code ▽ | Embed ▽ | No License
1


This is my second 3D game demo. But I am not finished it yet.
control:

common mode:
press ⬅️ to turn left
press ➡️ to turn right
press ⬆️ to move forward
press ⬇️ to move backward
press 🅾️ to shift to left
press ❎ to shift to mouse mode

mouse mode:(only available on splore)
use your mouse to turn around
press Key_S to shift to left
press Key_F to shift to right
press Key_E to move forward
press Key_D to move backward
press ❎ to shift to common mode

Done:
--basic raycasting
--textured wall
--static sprite

plan:
--animated sptite
--moving enemies
--shoot game
--dialogue

[ Continue Reading.. ]

1
0 comments


Cart #jugudirinu-0 | 2024-07-17 | Code ▽ | Embed ▽ | No License
2

2
0 comments


Cart #casheste1x2-0 | 2024-07-17 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
8

Bite-sized Celeste Classic mod.
Requires no tech.
Intermediate-Advanced difficulty. Designed with non-linearity in mind.

The character featured is Cash, designed by Lash sleeper. I do not own them.
This card was designed under 3 days for the artfight 2024 event.

v1.2 : Changed menu music (again)
v1.1 : Changed menu music
v1.0 : Initial release

8
4 comments


Cart #bomber-2 | 2024-07-17 | Embed ▽ | License: CC4-BY-NC-SA
4

Bomber for Picotron is an enthralling Flight simulator, where you can relive the battle of Poland, Ohio in the American Civil war, as one of the brave RAF pilots which fought in the battle of Poland, Ohio in the American United States of America North American American Civil War.

Vector Art: https://www.lexaloffle.com/bbs/?tid=141774
Font: https://www.lexaloffle.com/bbs/?tid=140803

(Piss: It is hard to win; you need to employ the same strategy used by John Earl Grey, captain of the RAF Squadron fighting in the battle of Poland, Ohio in the American Civil War)
(Piss Piss: Win + Loss screens for the battle of Poland, Ohio in the American Civil War do not work in the browser)

4
3 comments


Edit 18/07/2024: Cursor is omnipresent, fixed font.

Cart #hipshot_03-0 | 2024-07-18 | Code ▽ | Embed ▽ | No License
2

Edit 17/07/2024: Fixed interlocking issue and added square movement fidelity

Cart #hipshot_02-0 | 2024-07-17 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2

base upload

Cart #hipshot_01-1 | 2024-07-17 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2

[ Continue Reading.. ]

2
4 comments


Is test of worm

Cart #slinky_womrs-0 | 2024-07-17 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

Code

a={}
for i=1,20 do
 b={}
 b.x=64
 b.y=64
 add(a,b)
end

function _update()
 if (btn(0)) a[1].x-=1 sfx(0)
 if (btn(1)) a[1].x+=1 sfx(0)
 if (btn(2)) a[1].y-=1 sfx(0)
 if (btn(3)) a[1].y+=1 sfx(0)

 for i=2,20 do
 a[i].x=a[i].x*0.8+a[i-1].x*0.2
 a[i].y=a[i].y*0.8+a[i-1].y*0.2
 end
end

function _draw()
 cls()
 for z in all(a) do
 spr(1,z.x,z.y)
 end
end
0 comments


Cart #pudumarsu-0 | 2024-07-17 | Embed ▽ | License: CC4-BY-NC-SA
1

1
2 comments


Cart #pendulum_wip_25_07_2024-0 | 2024-07-24 | Code ▽ | Embed ▽ | No License
3

3
6 comments


Hey everyone.
What year do you think Pico-8 would've been released if it was a real console that physically existed?
Late 80's? 90's? Before or after NES? Let's talk about this.
P.S. Another topic, would Pico-8 be a hand-held or a home console? Personally, I think
it'd be a cube-shaped home console, square-sided just like its display. Similar to GameCube but more "cuber" (with equal dimentions) and quite small in size. Regarding the colors, i think dark grey body with a red outline would look stylish. Like on the picture, but a different color.

1 comment


Cart #bisiduyaya-0 | 2024-07-16 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
4

This is a proof of concept! It's a platformer where you use buoyancy to gain altitude. The deeper you dive, the more altitude you gain when popping out of the water! Kinda like a floatie in the pool.

Use left and right to move. Press X to dive deeper (when submerged) and O to move upwards (also while submerged). On land, press O to jump. Try to collect all the gems.

4
2 comments


Cart #stoolmod-1 | 2024-07-17 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
12

Madeline is climbing Mount Celeste again, but this time she's brought a stepstool to help her reach new heights.

Featuring difficult stool-based tech, new sprites, remixed music, 23 levels, and a secret ending!

Controls

Arrow keys - Move
C/Z - Jump
X/V - Dash

Down+X to pick up a stool, and X to throw it.
Hold Down while throwing to place the stool gently instead.

Credits

  • Original game by Maddy Thorson & Noel Berry
  • Music is a remix of "First Steps" by Lena Raine
  • Token sprite taken from newleste.p8
  • Stool mechanic is inspired by True North by Meep
  • Based on Evercore and Smoothleste

This thing has been in development for way too long. A large portion of it was procrastination, as I ran out of level ideas and I'd set the goal to have at least 24 levels. I think it turned out pretty cool though, and I can't wait to see what the speedrunners do to it :)

12
7 comments


Im don't put PCM sample in PICO-8 cartridges

0 comments


Cart #onewingfarmtime-0 | 2024-07-16 | Code ▽ | Embed ▽ | No License
1

1
0 comments


Cart #malte_brun-1 | 2024-06-16 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA


Madeline ventures into Oceania to conquer one of New Zealand's tallest mountains, Malte Brun.

I finally figured out how sprite flags work!
This is my second ever Celeste mod and technically my first mod with new mechanics.
Credit to the Evercore team for making the base cart and Antibrain for making the slab code.

1 comment


Hardoween Demake


Peppino's XMAS Break Demake


2
0 comments




Top    Load More Posts ->