Log In  

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

I've seen varying techniques for update looping and am looking for insight/feedback on if one is any better than the other in terms of speed/efficiency.

Method #1 I see a lot is a global table of all the actors on the screen. So everything goes here and then the system _update() function is something like this.

actors={}

function _update()
   foreach(actors, function(obj)
      obj.update()
   end
end

This method makes sense. Every object then has its own update() method...but that feels kind of inefficient, especially if the update would be the same for like-actors.

Method #2 is grouping like-actors with each group have its own update() method, which is then called in the system update loop.

bullets={}
bullets.actors={}
bullets.update=function()
   foreach(bullets.actors, function(obj)
      ...do stuff to obj...
   end
end

badguys={}
badguys.actors={}
badguys.update=function()
   foreach(badguys.actors, function(obj)
      ...do stuff to obj...
   end
end

function _update()
   bullets.update()
   badguys.update()
end

[ Continue Reading.. ]

2
9 comments


Cart #20797 | 2016-05-18 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
6



This cart is basically a demonstration of a simple tool/function I've made to check/debug the music playing in one of my project, the function need no external dependency and should not clobber your variables as all of them are declared as local. You only need to call the function with the Y position as parameter (positive number are relative to the top of the screen, negative from the bottom) in your update screen function to display a bar with the current status of music playing.

There are four zone, one for each channel, the green/red bubble indicate is the channel is playing or not (green == playing, red, not playing) the number next to the bubble is the pattern used on that channel, and the bar on the bottom is the current position in the pattern.

The function itself:

function debug_music(y)
  if y < 0 then
    y = 128 - 17 + y
   end
   rectfill(0, y, 127, y+18, 0)
   rect(1, y+1, 125, y+16, 7)
   for c=0,3 do
 	   local p   = stat(16+c)
 	   local b   = stat(20+c)*25 / 32
 	   local col = 8
 	   if p > -1 then 
 	     col = 11 
 	   end
 	   circfill(9+c*32, 6+y, 2, col)
 	   print(p, 15+c*32, 4+y, 7)
	   rectfill(3+c*32, 10+y, 27+c*32, 13+y, 6)
	   if p >= 0 then
		   rectfill(3+c*32, 10+y, 3+b+c*32, 13+y, 3)
	   end
   end
end

[ Continue Reading.. ]

6
5 comments


Cart #20632 | 2016-05-16 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
4

This is my first PICO-8 game :D

It was written entirely on a PocketCHIP, and was heavily heavily based on a tutorial found in the first issue of the PICO-8 zine.

It's a single-player PONGish game, the arrow keys can be used interchangeably with the action buttons to move the paddle.
After each 50 points the ball starts going faster! Extra lives are earned per each 100 points.

Good Luck!

4
6 comments


Cart #20624 | 2016-05-16 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
16

This is a classic style arcade shooter but RGB is about speed and accuracy rather than just shmup'ing destruction.

Match the color of your shot with the enemy color to increase score. Jump to different colored bars to change your shot color. There are bonus points for accuracy, not dying and speed.

Controls
Left/Right - Move your ship
Up/Down - Jump color bars
Z - Fires

This is my first real attempt at a Pico-8 game that has a future. This is just the first "demo" version right now. It only has 5 levels with no real satisfying ending or boss...that's all to come. There's some solid foundation to build upon so I hope to keep working and turn this into a nice little puzzle shooter.

Please leave feedback.

Todo List

  • Some sort of music (anyone want to help?)
  • Few more sounds
  • More bullet patterns
  • Boss levels
  • Power-ups or extra lives
16
9 comments


Hi,
I wanted to implement line of sight for a roguelike today so I started looking up Bresanham's algorithm and ended up writing a parametric version of it because mixing conditionals and iterators makes me barf. :p

I'm posting the implementation algorithm because I'm not sure if I'm doing things in a way that is blatantly wrong for Lua, or if there's a better way. I'm very new to Lua so, well, I'm kind of clueless about how to write good Lua software. I saw a few implementations around and was wondering what's the best choice for LOS in Lua, also considering that code points are a scarce resource and between them and heat maps I feel somewhat... constrained. So, yes, what's the best line-tracing implementation, given a metric of your choice?

Here's mine. It has as only advantage a clean iterator. :)

function los(x,y,x2,y2)
 local c_x = x -- x position of the cursor along the los
 local c_y = y -- y position of the cursor along the los
 local dx -- the deltas will determine how much to move the cursor along both axes
 local dy
 local i  -- how many real pixels long the line is. Not the diagonal nor the manhattan distance
 if (x == x2) then -- do not divide by 0 ;)
  dx=0
  dy = sgn(y2-y)
  i = abs(y2-y)
 else
  dx = x2-x
  dy = y2-y
  if (abs(dx) > abs(dy)) then
   i  = abs(dx)
   dy = dy/i
   dx = sgn(dx)
  else
   i  = abs(dy)
   dx = dx/i
   dy = sgn(dy)
  end
 end
 i = i-1 -- we only need to check that the intermediate positions are not occluding, not the start nor the end 
 for c=1,i do
  c_x += dx
  c_y += dy
  -- if you want to memoize that this location is visible from x,y, do it right here before the test
  if (obstruction_at(flr(c_x+0.5),flr(c_y+0.5))) then -- there's no round, only zuul
   return false -- no LOS
  end
 end
 return true -- ok LOS
end

[ Continue Reading.. ]

1
0 comments


Cart #roof14-1 | 2020-07-12 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
16

You're the driver of a semi-automatic roof repairing cart and you're undoing the damage caused by the meteorites. The roof of each house can only take so much damage before the entire house is destroyed.

Controls:
LEFT, RIGHT: Drive left and right.
UP, DOWN: Extend or retract the arm of the vehicle, holding the the repair rig.
Z: Use the repair rig on the roof. Make sure you're properly aligned with it (or get a perk which will do that for you)
X: Install an auto-repair unit (ARU) if you have some.

Scoring:
+25 points to undo the damage caused by one meteorite strike.
Level up after every 200 points scored. A randomly chosen house will grow in size upon leveling up. A perk shop dialog window appears.

[ Continue Reading.. ]

16
13 comments


Cart #20597 | 2016-05-15 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
18

I made a map maker for Pico-8! Unlike the built in map editor, it represents maps a little differently -- the format is a collection of rectangular tile fills + a bunch of entities you can place on top. It saves all maps together in a custom data format to the cartridge's shared map/tileset area. It has undo, redo functionality on the tile layer. And there's fun sfx as you edit stuff! The main benefit of this tool is that for maps with simpler layouts, expressing a map as a set of rectangular fills is much smaller than a 16x16 tilemap, so you can hold a lot more screens of map data than using the direct map editor. The less objects, the less map space required.

Anyone can feel free to alter this or reuse bits for their own maps. I made this for a little rpg project I've been planning out, and just to have fun. In-game instructions are included, but assume a default keyboard layout, rather than describing things in terms of player 1 and player 2 buttons. But I've included them here as well, for good measure!

DRAW MODE
Z = draw
X = undo
S = redo
A = tileset

ENTITY MODE
Z = draw
A = tileset

MENUS
Z = acccept
X = cancel

OTHER
F = file menu
E = toggle between draw and entity mode

There's no import/export cart functionality, but it's easy enough to add with reload()/cstore(), or just copying the data out of the gfx section in the p8 file.

18
6 comments






[ Continue Reading.. ]

8
2 comments


PicoTown 1.1b3

Cart #20608 | 2016-05-15 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
7

PicoTown 1.1b2

Cart #20605 | 2016-05-15 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
7

PicoTown 1.1b

Cart #20604 | 2016-05-15 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
7

[ Continue Reading.. ]

7
3 comments


I've made a little tool (Windows only) that helps saving time and keeping organized when working on bigger pico-8 projects. It might be useful to some of you so I'm sharing it here on my blog. To see what it does and does not do, please read the blog post before downloading.

UPDATE: P8Coder is now open source P8Coder on GitHub

19
21 comments


Cart #20549 | 2016-05-13 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

A simple snake clone I made. The next version will include sounds, a title screen, and a persistent high score.

W/A/S/D -move

X -stop

1 comment


Cart #tetromix-3 | 2021-09-07 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
20

Inspired by the PicoMino game, I decided to create my own attempt at replicating the famous Russian puzzle game.

Pretty much all the expected functionality is available, such as 1- and 2-player gameplay, preliminary sound and graphical effects, level (garbage height) and speed selection, etc.

MODES:

The game provides two modes: A (endless) and B (25 lines).

In the A mode, the game continues until any of the players top out (until the game can't put a new piece on top of the playfield).
In a 2-player game, the surviving player is declared the winner.

In the B mode, the game also ends if the player eliminates 25 lines of blocks.

[ Continue Reading.. ]

20
21 comments


Cart #20539 | 2016-05-13 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2

I made a small demo of a rotating globe. The texture effect works visually.
Feel free to reuse the code to improve it or to make awesome games!

2
0 comments


So this needs some explanation. I've never made anything even slightly resembling a video game before. I'm a completely amateur programmer. I'm mostly a journalist and a writer.

For a recent story I wrote, I had to set a goal for myself that I could accomplish in one week. I had seen some Pico-8 games floating around and wanted to give it a try, so I made a game about the experience I had writing the article.

It's pretty raw. It's basically a Simon Says race against the clock, there's no music and the only difference between the levels is you have less time each time. But I've never done anything like this before and I learned a lot in the process. And I had a lot of fun. I hope to improve on this and make another game soon :)

Cart #20527 | 2016-05-13 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

1 comment


Cart #20523 | 2016-05-13 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2

My first effort on Pico-8. Really fun to play with.

Controls:

Z: Restart
Left: Low jump
Up: High jump

2
1 comment


I have pico 8 up and running on my pi2. Everything seems fine except every special key (alt, shift, page-up, etc..) generates a space. Or at least something that looks like a space. This only happens in the console, the editor is fine, and works as expected. The keyboard is a generic en-usa usb keyboard, that works as expected everywhere else in the pi. My distribution is retro-pi current and up to date.

2
12 comments


Hi! Some folks on the IRC were struggling with metatables, and Ivoah suggested I post an explanation here to help more people get to grips with them. Here goes nothing:

A table is a mapping of keys to values. They're explained quite well in the PICO-8 manual so I won't go into more detail. In particular you should know that t.foo is just a nicer way of writing t["foo"] and also that t:foo() is a nicer way of calling the function t.foo(t)

A metatable is a table with some specially named properties defined inside. You apply a metatable to any other table to change the way that table behaves. This can be used to:

  1. define custom operations for your table (+, -, etc.)
  2. define what should happen when somebody tries to look up a key that doesn't exist
  3. specify how your table should be converted to a string (e.g. for printing)
  4. change the way the garbage collector treats your table (e.g. tables with weak keys)

[ Continue Reading.. ]

49
25 comments


Cart #20503 | 2016-05-12 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
13

I've never read Animorphs, but I have looked at the covers a lot.

(Press Z to transform)

13
3 comments


I discovered PICO-8 four days ago after reading a news in The Verge about the upcoming PocketCHIP. I purchased a license (the voxatron bundle) to see what it was about and since I can't stop playing with and the numerous games / demos.

I looked at some code, read some posts on the forum and thought it could be even more funny to code.

So I decided to start with a Lode Runner remake as my first program.
It might be a bit ambitious as it's been almost 15 years I haven't coded anything serious but I have some time and I'm decided to learn.

It's still at the very early stages, I managed to fit the first level into to 128x128 and draw the sprites set :

and I can display them together :

But that's it for now...

Part 2

Today, after a long weekend, I'm back to PICO-8 devellopement.
Lode Runner runs !

[ Continue Reading.. ]

10
26 comments


When compiled to HTML, it was surprisingly easy to inject data inside a PICO-8 cart.

The memory starting at 0x4300 (user data) maps to index 0x10DA1C of the heap in JavaScript. You can get and set the data easily using JavaScript (wait till the cart is loaded):

Module.getValue(0x10DA1C);
Module.setValue(0x10DA1C, 3);

Then read it or set in PICO-8 like this:

peek(0x4300)
poke(0x4300, 3)

I'm using it for a multiplayer game where I want to allow several players selection only when there is an internet connection (I haven't worked on the multiplayer communication yet though).

The user data section is 6912 bytes long, so that's a lot of data for PICO-8.
Potentially this technique can be used to do all sort of really cool things like leaderboard inside the cart, downloadable levels or players, syncing several players together (chat, collaboration games, multiplayer games...).

Caveats:

  • Not sure if the index in the heap will remain stable across releases. Is it even stable across carts? It must be decided by some internal logic in Emscripten.
  • It works only in web mode of course.
  • It works only when embedded in a particular web page.
6
11 comments




Top    Load More Posts ->