Log In  

BBS > Superblog
Posts: All | Following    GIFs: All | Postcarts    Off-site: Accounts

Cart #28248 | 2016-09-10 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
258

The goal of this cart is to demonstrate a very basic platforming engine in under 100 lines of code (comments don't count), while still maintaining an organized and documented game.

It is not meant to be a demo of doing as much as possible, in as little code as possible (a la demo scene). The 100 line limit is just meant to encourage people that "Hey, you can make a game with very little coding!"

This will hopefully give new users a simple and easy to understand starting point for their own platforming games.

Note: Collision routine is based on Super Mario Bros 2 and M.C. Kids, where we use collision points rather than a box. this has some interesting bugs but if it was good enough for miyamoto, its good enough for me!

Built on a PocketC.H.I.P.!

97
35 comments


Hi!

To celebrate my birthday, I thought I would share something with you guys! And having recently heard (again) that most of our codes weren't very easy to read, I thought I would share some readable code !!
I might do others of these in the future if you like it! But feel free to make some of your own, I'm sure it will help the community a lot!

Here is today's subject: Balloons That Explode Into More Balloons


And here is the commented code! (click to unravel)
[hidden]

Initializing some important stuff. You could do that in more appropriate places. Call me messy, i don't care.

bloons={} -- 'balloons' is long

shkx=0
shky=0

You can initialize stuff in the _init function too. The difference is that here you can call functions written after this.

function _init()
 createbloon(64,64,32,0,8)

 -- if you don't have any music
 -- just put some sfx at
 -- the beginning
 sfx(8)
end

Call updating functions in the _update function. Don't actually update anything here, it will get messy.

function _update()
 updatebloons()
 updateshake()
end

At first, partially and randomly clearing the screen for that weird trail effect.
Then, drawing the cool stuff.

function _draw()
 camera(0,0)

 for i=0,1999 do
  circ(rnd(128),rnd(128),1,0)
 end

 camera(shkx,shky)

 drawbloons()
end

Creating one balloon object
at x,y position,
with a bigger-circle ray of r,
a moving speed of spd,
and c as color.
Angle and rotating speed 'va' are random.
Life timer 'l' is also random, but always between 0.8 and 1.2.
Then adding the balloon object to the balloon array.

function createbloon(x,y,r,spd,c)
 local b={x=x,y=y,r=r,a=rnd(1),va=(flr(rnd(2))-0.5)*0.5+rnd(0.2),c=c,l=0.8+rnd(0.4)}
 local aaa=rnd(1)
 b.vx=spd*cos(aaa)
 b.vy=spd*sin(aaa)
 add(bloons,b)
end

Updating the balloon objects one by one.

function updatebloons()
 for b in all(bloons) do
  -- updating rotation 'physics'
  dma=abs((b.a+0.25)%0.5-0.25)
  vvv=-dma*0.005

  if (b.a+0.25)%1<0.5 then
   b.va+=vvv
  elseif (b.a+0.25)%1>0.5 then
   b.va-=vvv
  end

  b.a+=b.va

  b.va*=0.96

  -- updating position 'physics'
  b.x+=b.vx
  b.y+=b.vy

  if(b.x-b.r<0)   b.vx=2-b.vx sfx(4)
  if(b.x+b.r>127) b.vx=-2-b.vx sfx(4)
  if(b.y-b.r<0)   b.vy=2-b.vy sfx(4)
  if(b.y+b.r>127) b.vy=-2-b.vy sfx(4)

  b.vx*=0.9
  b.vy=0.9*b.vy+0.1*(-1)

  -- updating life timer
  b.l-=0.01
  if b.l<0 then
   -- timer is at its end...
   -- *boom!*

   -- creating five new balloons
   -- if exploding balloon is
   -- big enough
   if b.r>4 then
    for i=0,4 do
     createbloon(b.x,b.y,b.r/4+rnd(b.r/2),8+rnd(8),8+rnd(8))
    end
   end

   -- the 'oompf'
   circfill(b.x,b.y,b.r+2,7)
   addshake(b.r)
   sfx(flr(rnd(4)))

   -- delete exploded balloon
   del(bloons,b)
  end
 end
end

Drawing the balloon objects one by one.

function drawbloons()
 for b in all(bloons) do
  -- uncomment the outline
  -- for sweet graphics
  -- and low framerate

  --outlined(drawbloon,7,b)
  drawbloon(b)
 end
end

Draws one balloon.
It's actually several circles, smaller and smaller, going from balloon's x,y position, along its 'a' angle.

function drawbloon(b)
 for i=0,7 do
  circfill(b.x+i*(b.r/8)*cos(b.a),b.y+i*(b.r/8)*sin(b.a),(1-(i/16))*b.r,b.c)
 end
 local rrr
 if b.r>10 then rrr=2
 else rrr=1 end
 local rr=7*(b.r/8)+(1-(7/16))*b.r+rrr
 circfill(b.x+rr*cos(b.a),b.y+rr*sin(b.a),rrr,b.c)
end

Addshake adds a screenshake of 'p' power.
You have to call updateshake every once in a while (on _update for example) and use 'camera(shkx,shky)' before drawing stuff for the screenshake to actually work.

function addshake(p)
 local a=rnd(1)
 shkx+=p*cos(a)
 shky+=p*sin(a)
end

function updateshake()
 if abs(shkx)+abs(shky)<0.5 then
  shkx=0
  shky=0
 end

 shkx*=0.7+rnd(0.2)
 shky*=0.7+rnd(0.2)
end

Makes every color being drawn as the color 'c'.
Calling 'allcolorsto()' resets it.

function allcolorsto(c)
 if c then
  for i=0,15 do
   pal(i,c)
  end
 else
  for i=0,15 do
   pal(i,i)
  end
 end
end

Outlines in color 'c' whatever drawing function's callback is set as 'draw'. Also feeding that function with 'arg' as argument (you can also use it as 'outlined(draw,c)' if 'draw' doesn't need any argument, it will work too).

function outlined(draw,c,arg)
 allcolorsto(c)
 camera(shkx-1,shky)
 draw(arg)
 camera(shkx+1,shky)
 draw(arg)
 camera(shkx,shky-1)
 draw(arg)
 camera(shkx,shky+1)
 draw(arg)
 -- uncomment for shadow effect
 --camera(shkx,shky-2)
 --draw(arg)
 camera(shkx,shky)
 allcolorsto()
end

[ Continue Reading.. ]

19
4 comments


šn¿ÆØœ‰Ó.com¤Ïšn¿Æ˜I½ç´ó¼‰¤Î¥¤¥ó¥¿©¥Í¥Ã¥Èͨ؜¥µ¥¤¥È¡¢¼¤°²¥ª¥ó¥é¥¤¥ó¥·¥ç¥Ã¥Ô¥ó¥°¥³¥ß¥å¥Ë¥Æ¥£¤Ç¤¹¡£šn¿Æ™CÆ÷¼°¤Ó¼¼¹¤²ÄÁϤʤɤ¬¼¤°²ý¸ñ¤ÇÆ·ÊýØN¸»¤Ë´ó¼¯ºÏ£¡šn¿ÆÒ½Ôº¡¢¼¼¹¤Ëù¤Ë¥»©¥ëÉÌÆ·¤äšn¿ÆÓÃÆ·¡¢²ÄÁÏ¡¢œç¾ú¸ÐȾÓè·ÀÆ·¤òµÍ¥³¥¹¥È¤ÇÌṩ¤·¤Þ¤¹
Ô”¤·¤¤Çéˆó¤Ê¤é¡¢¤³¤Á¤é¤Ç¤¹http://www.shikahanbai.com/

1 comment


Cart #28217 | 2016-09-09 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
78

78
6 comments



A super simple game I made for the Etsy Pico-8 game jam.

1 comment



Just for fun!

2
0 comments


Cart #28197 | 2016-09-08 | Code ▽ | Embed ▽ | No License

It's just a Tic-Tac-Toe game.

Rules :

  • Do a line with 3 cross/circle to win

To add later :

  • AI to play against the player
  • Add music/sound effect (SFX when drawing a cross/circle is pretty annoying)
5 comments


Cart #28170 | 2016-09-07 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
12

This is a TAS (Tool-Assisted Speedrun) of CELESTE. Uploaded here so you can watch it on your home PICO-8 console :)

EDIT: Doesn't seem to work on PocketCHIP for some reason...

If you'd rather just watch a video, you can see it here:

12
10 comments


Cart #28140 | 2016-09-07 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA


Thank you for playing.
This is my first game.

2 comments


I uploaded a test cart to the BBS but didn't make a post for it. Now the test cart shows on my user carts page, but I cannot delete it. It also says it has 8 stars somehow XD

Is there any way to delete carts from the BBS, or at least keep them from appearing on my user carts page?

Thanks

EDIT:
loll okay nevermind; now that I just posted this, I looked again and the test cart is gone. Is there some cron job that cleans up orphaned carts periodically or something? XD

0 comments


Cart #29780 | 2016-10-01 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
112

Time your speed and angle in an attempt to throw a Frisbee as far as possible. Then take control of the receiving player, and position yourself for the catch! If you do manage to catch it, quickly throw it again. Keep going until the Frisbee hits the ground, and see how far you can make it!

An update to the classic "Flying Disc" mini-game from California Games.

Update September 30th, 2016 (version 1.0):

Considering this game done! Moving out of WIP section.

Update September 18th, 2016 (version 0.4):

[ Continue Reading.. ]

112
25 comments


hi!

this is my remake of this music: http://zxart.ee/rus/avtory/x/xpeh/sokomix/

free to any use. download here http://rgho.st/8fd2WWFxx

7
7 comments


Cart #28083 | 2016-09-06 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
3

Hey there!

Blob Smasher is a game we made during the BBQ Game Jam 2016, which is a 24-hour jam during which you spend more time eating grilled stuff than actually creating something.

Florian & I went with pico8 for the fun, and it's our very first experience with it and lua.

Blob Smasher is a 2-player versus game. Smash the blob to divide it and throw it at your opponent. Don't get touch by a blob while it's of the opposite color!

3
2 comments




Simple Voronoi diagram generator. I was trying to see if I could get a speed boost from writing pixel values directly to the video RAM, but regardless the fill walking through all the pixels is still very slow. Any ideas on how I could speed things up?

--voronoi diagram
--by hypothete
points={}

function makepoints()
	for i=1,16 do
		e=rnd(128)
		f=rnd(128)
		add(points,{
			x=e,
			y=f,
			c=rnd(255)
		})
	end
end

function jitter()
	for i=1,#points do
		p=points[i]
		p.x+=rnd(2)-1
		p.y+=rnd(2)-1
	end
end

function near(pts,b)
	nt=nil --nearest pt
	nd=4096--dist to nt
	for i=1,#pts do
		a=pts[i]
		nl=(b.x-a.x)^2 + (b.y-a.y)^2
		--dist leaving off sqrt
		if(nl<nd)then
			nd=nl
			nt=a
		end
	end
	return nt
end

function drawvoro()
	for i=0,63 do
		for j=0,127 do
			k=i+64*j --x+y*w = 1d position
			z={x=i*2,y=j}
			np=near(points,z)
			if(np) then
				memset(0x6000+k,np.c,0x1)
			end
		end
	end
end

function _init()
	makepoints()
	drawvoro()
end

function _update()
	if(btnp(5)) then
		jitter()
		drawvoro()
	end
end
6
9 comments


Cart #28051 | 2016-09-05 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

Very straightforward game thrown together in about 80-90 minutes when I realised nothing was really getting ready/finished for August's #onegameamonth.

Control a rad person as they aim to save their precious physical media from the dastardly rule of scissors.

Arrows to move, avoid scissors, collect CDs.

I actually did sound effects (limited, but present!). Quite happy with the speed/completeness of this, full disclosure though I have a basic 3-state template (update/draw for title, game, endgame) which I loaded up as boilerplate so that I could maximise the time I had.

Enjoy!

0 comments


I took some time to rewrite things so that a more deliberate architecture was in place before moving forward with more changes. I wouldn't exactly call it "clean" at this point, but it's better. I'd happily listen to feedback on architecture once I've released it.

For now, a screenshot of my first finished game in Freecell for PICO-8. Lots to do still! I'd like to strike a balance that saves button presses without turning the game too much into "autopilot." As it stands right now, it requires far too much input though.

0 comments


Cart #28048 | 2016-09-05 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

0 comments


Cart #28139 | 2016-09-07 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
11

-- 0.5 --

  • Added blinking text cursor
  • 1646 tokens

Cart #28131 | 2016-09-07 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
11

-- 0.4 --

  • Numbers & Symbols keyboard
  • (Potentially annoying) keyboard sounds
  • Weird bug fix for the PocketChip version of Pico-8
  • Token count has creeped up to 1529

Cart #28095 | 2016-09-06 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
11

[ Continue Reading.. ]

11
3 comments


Cart #28037 | 2016-09-05 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1

This is a silly little dungeon crawler I put together to learn PICO-8. It hasn't been balanced at all and is way too difficult right now. There's also only one level; the stairs are a lie :).

TODO:

  • Player buffs
  • More levels
  • More enemies
  • Better dungeon generation
  • Possibly an end condition
  • High scores table
1
4 comments


Couple people asked about how I did sprite rotation for josefnpat's collab cart https://www.lexaloffle.com/bbs/?tid=27582
Included is a sprite rotation function, and a way of layering them on top of each other to create an illusion of a 3d sprite.
Everything is commented, hopefully it's clear.
Enjoy, hope this is helpful for someone!


(the effect isn't perfect and can be a little unclear if you don't consider it when drawing sprites, if anyone has any more accurate examples of rotation functions I'd like to see!)

14
6 comments




Top    Load More Posts ->