Log In  

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

Here is a simple function to convert a number to its hexadecimal string representation:

function num2hex(number)
	local base = 16
	local result = {}
	local resultstr = ""

	local digits = "0123456789abcdef"
	local quotient = flr(number / base)
	local remainder = number % base

	add(result, sub(digits, remainder + 1, remainder + 1))

  while (quotient > 0) do
  	local old = quotient
  	quotient /= base
  	quotient = flr(quotient)
  	remainder = old % base

		 add(result, sub(digits, remainder + 1, remainder + 1))
  end

  for i = #result, 1, -1 do
  	resultstr = resultstr..result[i]
  end

  return resultstr
end

Usage:

	print(num2hex(255)) -- ff
	print(num2hex(10)) -- a
	print(num2hex(1050)) -- 41a
2
3 comments


Cart #50120 | 2018-03-09 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
22

This is my very first PICO-8 game, I hope you like it!

It's a sokoban style game with 15 levels, it features deadly traps, gems and lasers!
Post your times if you finish it. Thank you!

22
9 comments


I love the simplicity of Pico, but for quick coding like in Game Jams it's nice to have a foundation to work off of. That's why I wrote this toolkit that provides some basic functionality like debugging and physics. Has anyone else done something like this before? Should I add anything else?
Thanks!

3 comments



Have fun testing your brand new Renault engine in Barcelona.

0 comments


Cart #50050 | 2018-03-07 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

1 comment


there's poke() and poke4(), where's poke2()?
I'm tinkering with sfx mem right now, and the notes are 16 bits...
I know, I'm never happy ;)

--do not use this! the proper version is by Felice below
function poke2(a,w) poke(a,w) poke(a+1,w/256) end
function peek2(a) return peek(a)+peek(a+1)*256 end
12 comments


Converting shr() safely to simple math:

shr(v, 16) ==> v * 0x.0001
shr(v, 15) ==> v * 0x.0002
...
shr(v,  2) ==> v * 0x.4000 (or 0.25)
shr(v,  1) ==> v * 0x.8000 (or 0.5)

Multiplying by the fraction avoids a hazard where a negative number can go to 0 when dividing by numbers greater than 1, which destroys the sign-extending upper bits you expect to keep with shr().

It also allows shifts up to 16, whereas dividing only allows shifts up to 14. This is because PICO-8 can't represent any powers of 2 larger then 16384.

Similarly, because it is safe to divide by a fractional number less than 1, you can use the same idea to shift left up to 16 bits:

shl(v, 16) ==> v / 0x.0001
shl(v, 15) ==> v / 0x.0002
...
shl(v,  2) ==> v / 0x.4000 (or 0.25)
shl(v,  1) ==> v / 0x.8000 (or 0.5)

In this case, it's down to style or the need to shift by more than 14. Unlike dividing, multiplying by values greater than 1 is safe, so you can also obviously just convert shl(v,2) to v*4. PICO-8 performs divides as fast as multiplies, so performance is the same either way.

Basically, your safe bet is always to use the fractional power of two, whether dividing or multiplying. If you want to be sure, start your constant with "0x." and you'll always get it the right way around. :)

The reason some of us want to do this, rather than the more-intuitive shift calls, is that it saves one token per shift. That can add up quickly in a program heavy with binary math.

3
1 comment



My first entry for the Pico-8 #tweetjam hashtag on Twitter. Unfortunately, I couldn't put in collision detection for the road boundaries without running out of the imposed 280 character limit, but I managed to cram in the sideway collision. That landscape... Amazing!!:)

0 comments


Cart #50017 | 2018-03-06 | Code ▽ | Embed ▽ | No License
3

Yesterday, I try to create different think. First, I create a little auto tilting system in PICO-8 from this article.

Cart #50018 | 2018-03-06 | Code ▽ | Embed ▽ | No License
3

After that, I create a maze generator with the Drunkard Walk algorithm (more information here). It's not very hard but I spend time on that. Finaly, I add a player, and a little hitbox system (with PICO-8 flag systeme), some monster (with lot of bugs), some coins and an exit. I've create a Rogue Like! I think I'm going to add some mecanics so, stay tuned on my Twitter!

3
1 comment


Cart #50316 | 2018-03-12 | Code ▽ | Embed ▽ | No License
9

Description

This is my platformer in the style of classic Mario games. I called it Platformer Base because I can't think of a good name. Play as the guy with the green helmet, jump on robots and stop their evil machinations once and for all!

Instructions

The game is fairly simple. Jump on the robots with O, and make it to the end of the stages. You can play them in any order you like.

Version

The current version is 1.2 and features the following changes:

+Added a flag that prevents autojumping
+Added SFX that can be toggled on and off

All previously published versions can be found Here.

9
4 comments


Cart #49989 | 2018-03-05 | Code ▽ | Embed ▽ | No License

0 comments


On yonder thread, where you wisely noted we should stop polluting its subject, you responded to me and said:

[box=404040]Static preprocessors like cpp are a weird fit for dynamic languages like Lua. For example, cpp-style includes have no order-dependent side effects in the languages they're used for (other than in the preprocessor macro language itself, I think?), so they can more simply insert code at first mention. This is not the case in Lua. Lua modules make the handling of side effects in the code explicit, so there's no confusion as to what a require() is expected to do. I'm very interested to know why a Pico-8 developer would prefer an #include-like to a require() because I can't think of a reason, as long as require() is implemented correctly.

Re: defines and such, I think what we actually want, especially in the context of Pico-8, is build-time constant folding and dead code elimination.

But we should take build tool discussion somewhere else, so people can use this thread to discuss Compos. :)

[color=#ffaabb] [ Continue Reading.. ]

16 comments


Cart #49975 | 2018-03-05 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2

'x' to simulate. 'c' to reset.

A 1D heat diffusion demo where you can draw your own initial conditions.
The solve is via convolution with the heat kernel.

2
1 comment


Cart #49970 | 2018-03-05 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1

Four of us made this in 24 hours last weekend as part of the midwestgamejam.

Move your tentacle around and press X to move your head toward your tentacles. Subsequent levels are more difficult, because the actions of your tentacle on previous levels are replayed.

1
0 comments


EDIT: Fixed as of 0.2.0!

Original post:


Pretty sure when you originally added _update60(), you compensated for the doubled frame rate when returning time() values, but these days time() is running at double speed when you have _update60() instead of _update().

I noticed this when playing with a simple seven-segment-display demo. Here's one that uses update() and updates once per second as expected:

Cart #49956 | 2018-03-05 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

And this is the same cart, but switched to _update60() and runs twice as fast:

Cart #49957 | 2018-03-05 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

1 comment


Cart #50264 | 2018-03-11 | Code ▽ | Embed ▽ | No License
3

By Ace + 15

3
7 comments


Cart #49937 | 2018-03-04 | Code ▽ | Embed ▽ | No License
2

BROOKSATRON was a little "game jam" experiment I made with my little sister. We sat down one afternoon over Thanksgiving and I showed her what sort of wonders PICO-8 had to offer. Over the next couple days, she drew most of the sprites, composed the music, and drew out the levels. It was a lovely weekend.

2
1 comment


Cart #49930 | 2018-03-04 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

0 comments


Cart #49928 | 2018-03-04 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1

Protect your code from the failure!

Create in1 Hour for the 149th One Hour Game Jam with the theme Failure

Controls
Arrow key - Move

Itch : https://bigaston.itch.io/code-failure-1hgj

1
0 comments


Inspired by the TweetJam-thread, I tried to make a small game myself - but I ended up at 594 chars (though not optimized at all).

Anyone know how to make this smaller?

(It's an "Air Combat" Mini Game... try to shoot down the attacking planes - before they get you! Controls: Arrows and X to shoot. C to restart.)

/ Pingo

Cart #49919 | 2018-03-04 | Code ▽ | Embed ▽ | No License

6 comments




Top    Load More Posts ->