Hi,
I've made two games in pico-8 until now and because pico-8 is meant to be both a fantasy game system and a development environnement, I wanted to make sure that my code could be read inside the pico-8 editor.
The problem I came across is that lua is highly verbose. That means that writing a simple if else statement takes almost all of the screen width. Since pico-8 already include some shorthands such as += or -=, I though we could have some more to reduce the number of characters used in code. This could be useful for future twitter jam eventually.
so I've read a bit of the lua doc to know which keywords and which tokens are already used:
--used keywords and break do else elseif end false for function goto if in local nil not or repeat return then true until while --used tokens + - * / % ^ # & ~ | << >> // == ~= <= >= < > = ( ) { } [ ] :: ; : , . .. ... --token added by pico-8 += -= *= /= %= != ? |
And here is my second game.
After making the chess game, I though it would be fun to make a GO game.
The game is playable and implement a counting
system to display the score at the end of the game.
Now there is a message asking the player if he's sure he want to pass his turn.
And we can switch the final screen between score and territories.
RULES:
While playing,
Press button O to place a stone (goishi),
Press button X to pass your turn,
The game ends when both players have passed their turn twice in a row
When the game ends,
Press button O to declare a group of stones as dead,
Press button X to display the score
Once the score are displayed, the game is definitely over
At the very end, you can switch between
territory and scoreboard with button O or button X
Here is my first pico-8 game
Since pico-8 has a 128128 screen and 88 sprites,
I though it would be fun to make a chess game in it.
The game is now fully playable
And I've recoded the whole thing so it runs faster
The game needs to run all possible moves of the next turn to define
if a move is valid or not and if it should be presented to the player.
It implements pawns double step, pawn promotion, castling and en passant.
Have fun.
Older versions:
With the introduction of the function type()
it is now possible to know the type of the variable.
So I tried to find a way to implement a simple class system and I think I found a way
First we need a function to copy tables
function copy(o) local c if type(o) == 'table' then c = {} for k, v in pairs(o) do c[k] = copy(v) end else c = o end return c end |
then we can declare our objects the following way:
vec = {} vec.x = 0 vec.y = 0 function vec:add(v) self.x += v.x self.y += v.y end function vec:subs(v) self.x -= v.x self.y -= v.y end function vec:mult(c) self.x *= c self.y *= c end |
to create multiple instances of vector, we just need to copy the object and edit it's attributes
a = copy(vec) b = copy(vec) a.x = 1 a.y = 2 b.x = 3 b.y = -1 |