Hi everybody!
It's been some time since I posted around here, and worked with Pico8 in general. Was a tough summer. But I come back with a second wind, partly because of the arrival of my PocketC.H.I.P.
Last Friday I started a project while I was on a train, to test out the device and how comfortable was to actually code with it. And I decided to post here some updates about the development of said project. So, without further ado:
--------------------------------------------------------------------------------------------------------------------------------
Behavior Trees
Most of you probably know about them, and have worked with them. For those which do not, I'll provide a quick explanation. Please correct me if I'm wrong, as I'm by no means an expert in this matter.
The Behavior Tree is a model widely used in the videogame industry to create goal-oriented plans using small, self-contained, behaviors. They came out in a conference about Halo 2 AI systems, and since then they've been used in lots of different projects, even outside of the domain of videogames (robotics, etc).
A behavior tree(BT) works by going through its nodes, from the root towards the leaves, computing these nodes according to certain rules.
The possible outcome of a node Tick() function is either Success, Failure or Running (usually). Each node computes its Tick() function analyzing the outcome of its own children.
e.g: The Inverter node's Tick() will return Success if its unique child returns Failure, and Failure if it returns Success.
So, in each Tick() (usually inside an Update() function), the tree will be computed and only some behaviors will activate, creating a composed, more complex, behavior.
If you're interested in reading more about them, here are a few nice links to articles and posts:
Gamasutra Article
Greetings:
I got inspired into making music again after looking into vaporwave. The problem is that I never was any good at making music. After tinkering a bit in the note editor in the Pico-8, I decided that I am better off learning from actual good loops and making a song off them.
The problem here is that the Pico-8 uses both a bar-based editor and a sort of tracker in composing its notes. So far, there doesn't seem to be any way to import any music or even loops into the Pico-8 cartridge format.
Is there some place where I can find loops in either the public domain or Creative Commons (preferably BY or BY-SA) and are in a format that lets me transcribe then into the Pico-8?

I'm new here and trigonometry is still a bit complicated for me. I'm not quite sure where to start on this, so sorry I can't really be specific, but I've been wanting to make a field of view.
I have no idea how to tell the game which squares to check for vision and how to block vision. As a newcomer to all this, what do I need to learn?

Version 0.4!
CHANGELOG
- Red platforms now drop down as you hit them, but not enough you can jump on them forever
- Added yellow platforms that slide from left/right at random speeds
- for difficulty increased the change of getting non green platforms the higher your score
- background slowly moves as you play, not sure I like that yet.
- platform won't generate with X starting past 120 now so they aren't half off the screen
- increased the randomness of Y when generating platform so they hopefully aren't as grouped

Well, THIS was a surprising side of myself to find coming to life while messing with PICO-8. Little as I've been able to really sit down and focus, I've actually started getting more into hardware and Linux now as a result of my exposure to it! I've already built a "Picade Console unit," and got that loaded up with some games... for some weird reason, Emulation Station still having trouble launching PICO-8, even though it can see the games there for it. I've done the "sudo chmod +rwx pico8" thing too. But nevertheless, the controller/unit was FUN to build, and that's something I really haven't done in a good ten years now. I'm up and playing a bunch of cool classics with it, too! I'm probably gonna get a full Picade Cabinet kit when they become available again, too! :D
Also, after MUCH delibration, my PocketCHIP finally shipped as well! It's only been a day now, and I had to do some calibration to the touch screen, but developing for PICO with it is still fun and solid! The somewhat nonstandard punctuation is a little tricky at first; but once you get acquainted a bit, it's pretty solid. I didn't have as much trouble hitting diagonals as I expected to have, from what I've heard here - but getting my right thumb back on the 0/+ keys (the Pocket edition equivalent of o/x or z/x) usually involved me looking away from the screen for the placement. It also felt weird trying to compose sound with "Q 2 W 3 E 4 R T 6 Y 7 U" since the number keys THEMSELVES were in a piano-like arrangement at the top of the screen (that might be one version difference worth considering); but once I popped up an octave and stuck to "Z S X D C F V B H N J M," it wasn't so bad. Then if I needed the top octave, I'd just change that bit in the tracker view. Editing sprites, maps, and even code felt natural as feck, though. And it's kind of a neat touch that it boots in Splore mode... but I can understand why the regular version doesn't do that.
It also feels REAL DAMN GOOD to have my first entire weekend off since June. T.T But I suppose without that intense grind, I wouldn't be swimming in all the cool nerdy wares I have going on now! And it's all 100% thanks to the PICO-8 community.
Created so I could learn how to handle tracker and maps (sort of...)
Inspired by tjheslin1's Interstellar I took yet another try to learn how trackers work and I just had to choose my favourite tune from Terminator 2!
Made in Pocket C.H.I.P. where I coudn't manage to make a screenshot so tips would be appreciated!
This is also my introduction to Pico-8 community!
Cheers everyone!!

For the game I'm working on I built a super tiny tweening system for making it easier to move things around. This cart demonstrates a few different easing functions that plug into the system.
Tweening is a way of moving an object from point A to B. You specify where you want the object to go, and how long you want it to take to get there, and the tweening system takes care of the motion. I find it super useful for making games, especially for adding little bits of polish to your game. It's easier to just say "move the ball to x=104 in 60 frames" than it would be to calclate the required speed every time. You can also use an easing function to tell how it should get there, allowing it to accelerate slowly or bounce or spring back.
Tweens have four parameters: the property we want to update, the value we want to end up with, the length of time we want it to take to reach the target value, and the easing function. We'll store those values in a table, and each frame we'll look at each entry in the table and update the target property as needed.
The tween function begins tweening a property:
function tween(target, property, destination, duration, func)
local tween_info = {
target = target,
property = property,
base_value = target[property],
change = destination - target[property],
duration = duration,
elapsed = 0,
func = func
}
add(tweens, tween_info)
end
|

So I've been looking for a quick and portable developer environment for me to gamedev on the go, and I thought pico-8 was it; but after trying for a while I'm not entirely sure....
I've already gotten a pocketchip and pico8 on pc >_>. But it feels really confusing after using Unity, gamemaker, and other more graphically based programs. I've tried making a sort of starting point for quick deving with objects and built in collision detection but its really difficult....
Any suggestions on where to start again or if there's a different programming environment I could work with?
EDIT:
I'm asking because I was trying to find a very quick and portable developer environment and that seems to be very hard to find and I'm not sure if this is right for me because I want to dev on the go >_<

I recently made a program that can translate (some) MIDIs to PICO-8 tracker format and I thought I'd also make a fun visualizer to show it off :)
The music you see (and hear) above is J.S. Bach's Sinfonia 15 in B minor (BWV 801). It was translated from a MIDI file (that I found on the internet somewhere) into PICO-8 tracker format by the aforementioned tool:
https://github.com/andmatand/midi-to-pico8
This visualizer takes a simple approach of displaying whatever notes it sees are currently playing each frame (if any notes changed) so it may skip notes if the notes ever change faster than the FPS (this cart runs at 60). A more robust visualizer could be written, but I just wanted something that could display most normal songs for fun :)
You can use this visualizer to display your own music by downloading this cart and uncommenting one or both of these lines in the _init() function (and changing the path string appropriately):
-- load the music and sfx data from another cart --reload(0x3100, 0x3100, 0x1200, 'othercart.p8.png') -- permanently store the music and sfx data loaded above --cstore(0x3100, 0x3100, 0x1200) |

This is a simple one - it's an over-engineered Pico-8 version of this Commodore 64 BASIC program:
10 PRINT CHR$(205.5+RND(1)); : GOTO 10 |
It's a random maze generator, and some folks wrote an interesting book about it

Or you could read that subject line as, "No Objects For Noobers."
For those of you confused or confounded by Object-Oriented programming, you might be happy to know that PICO will also accept the standard spaghetti-code variety. That is where there are no system interrupt or timing routines.
How do I use a single tile to create a perfect black outline around a sprite that is already 8x8 pixels in size ? You'll have to look at the code to find out. :)
Based on DittoSlash's test cart.

Inspired by LRP's lowercase font, I made a little library that lets you print to the screen using a custom 9px variable-width font that is defined entirely in code. In other words, nice and readable text that doesn't use sprites. The cartridge includes the hastily coded example usage you see above.
What's included:
init_print9
initializes font data, must be run before print9() can be used
print9 str [x] [y] [col]
prints to the screen using a variable-width 9px custom font
if x or y are left blank it will continue printing where it last left off
col is text color
optionally returns the x-coordinate of the cursor, which is useful if you
want to continue where you last left off (for example, when typing one
character every frame)
do note that print9() uses up a reasonable amount of cpu, typing out the
entire lowercase alphabet uses up about 10% of the cpu @ 30fps
my suggestion for longer text (i.e. dialogue boxes) is to draw to regions of
the screen that are not cleared every frame and only clear when necessary
is_bit_set var pos
checks if the pos-th bit (including fractional part) in var is set or not
used internally by print9(), but hey, it's a nice utility
|

Posting this for anyone who wants to use it. I had made this as practice awhile back and I hate to see the graphics go to waste. Originally I thought maybe I'd make a LITTLE COMPUTER PEOPLE clone (if you remember that for the C64) or some sort of sidescrolling adventure game, or even maybe as a "cheerleader" for a shooter/puzzle type game (she could react to how well or badly you're playing.)
If you download the cart, you'll see that there are 2 sprites with blank faces, a lot of faces for front and profile view (demo only uses 1 face), and a ground tile set, and a flower accessory sprite, and a walking sprite which does have a face.

64 values of save data ain't enough for you? Try using this! These functions will allow you to save up to 2,048* values in persistent data! Anyone's free to use it in their own projects; I'm personally releasing this under CC4-BY-SA to allow works using these functions to be sold.
*If you only accepted ON and OFF as acceptable values.
Here's a comprehensive manual on how to use these functions:
[hidden]
============================================================
Pico-8 Binary Functions Set
PRGM ver. 1.1.1
Created by A-zu-ra MANUAL ver. 1.1.2
============================================================
This function set includes functions that will:
- Convert a given integer into a 16-item table of
binary values
- Read a portion of the generated 16-item table
- Insert a given table into another table at any position
- Converts a given table of binary values into an integer
Through these functions, you can essentially use one integer
to serve multiple purposes. This document will not only
cover how the functions work, but also how to apply them in
the context of Pico-8's persistent data.
Included with this function set is a brief test program
showcasing all of the functions in action.
INT COUNT increments once a frame in both whole number
and decimal and is a base for all of the functions in
the test.
BIN START is the START variable of binread.
BIN RANGE is the RANGE variable of binread.
BIN TO INT tests reconversion of binary back to integer.
BIN TO DEC tests reconversion of binary back to decimal.
B2I + B2D is the values of BIN TO INT and BIN TO DEC
as a single value.
RANGE B2I is the integer value of binread.
INSERT B2I is the integer value of binread inserted into
another table via binins.
RANGE B2D and INSERT B2D work the same as RANGE B2I and
INSERT B2I, but for the decimal subset.
The bottom of the function test contains the RAW BINARY of
the integer, as well as the range of binread and starting
point of binins visualized. In the test code is a section
that has EDIT THESE BELOW VALUES! and EDIT THESE ABOVE
VALUES!, so feel free to experiment with the values to get
a better feel of how things go together.
------------------------------------------------------------
inttobin(value, decimal)
value An integer within Pico-8's acceptable range
(-32768 to 32767)
decimal A boolean that decides whether or not to pull
from either whole number or decimal (0 or 1)
RETURNS a table with 16 values of either 0 or 1
This function takes an acceptable value that you give it
and creates a 16-value table, each containing either a
0 or a 1 in it. The following examples are formatted to
be human readable; the order is reversed when the table
is created (i.e. the first example below is, from the
table's perspective, 0000100000000000).
16 0000000000010000
136 0000000010001000
9570 0010010101100010
-32768 1000000000000000
-3530 1111001000110110
------------------------------------------------------------
binread(table, start, range)
table A table generated via inttobin
start The starting point to read from
(remember, tables are 1-indexed)
range How many values from the starting point
to read from
RETURNS a table with a number of values
specified in range
This function takes a table that is generated from
inttobin and extracts a user specified portion of it.
This function requires two more additional values: the
starting point (so you can choose from a different
section of the table), and a range (so you can extract
larger values).
Since the table has the binary values in reverse order,
the function will appear to go from right to left when
imagining the ranges in a human readable order. The
following examples will hopefully give a better visual
of this.
Assume that table is {1, 1, 0, 0, 1, 1, 0, 0,
1, 1, 0, 0, 1, 1, 0, 0}.
(table, 1, 1) S
0011001100110011 bintoint: 1
(table, 1, 5) E S
0011001100110011 bintoint: 19
(table, 4, 7) E S
0011001100110011 bintoint: 102
(table, 9, 4) E S
0011001100110011 bintoint: 3
------------------------------------------------------------
binins(table, table2, start)
table The table you want to append values to
table2 A table generated via inttobin or binread
start What point in the target table to start at
RETURNS the target table with table2 appended to it,
starting from the bit position specified by the user
This function allows you to combine one table into
another at any place. It's advised that you calculate
the size of the table that you want to insert if you
plan on using this function multiple times on one table.
Much like the binread function, the function will appear
to go from right to left when imagining the start point
in a human readable order.
Assume that the target table is empty.
table2 = {1, 0, 0, 1} -- 1001
(table, table2, 1) S
0000000000001001 bintoint: 9
table2 = {1, 0, 1, 0, 1, 1} -- 110101
(table, table2, 4) S
0000000110101000 bintoint: 424
table2 = {0, 1, 1, 0, 1} -- 10110
(table, table2, 7) S
0000010110000000 bintoint: 1408
Remember to calculate your table sizes.
table2 = {1, 0, 1, 1} -- 1101 YES
table3 = {0, 1, 1} -- 110
(table, table2, 3) 3 2
(table, table3, 8) S S
0000001100110100 bintoint: 820
(Both tables added in with no
problems)
Otherwise, calling the function again will overwrite
those bits if the sizes conflict with the positioning.
table2 = {1, 0, 1, 1} -- 1101 NO
table3 = {0, 1, 1} -- 110
(table, table2, 6) 3 2
(table, table3, 8) S S
0000001100100000 bintoint: 800
(Table 3 overwrites last two bits
of table 2)
------------------------------------------------------------
bintoint(table, decimal)
table A table generated via inttobin, binread, or
binins
decimal A boolean that decides whether or not to write
to either whole number or decimal (0 or 1)
RETURNS an integer representation of the binary table
This function will take a binary table that you give it
and convert it back into an integer.
0000000000001000 8
0000000001000010 66
0000101000101000 2600
1000100100001000 -30456
------------------------------------------------------------
How to apply code in context with Pico-8 persistent data
-- Two 8-bit values (43 tokens)
c = {}
v = {6,6}
for i=1,#v do
binins(c,binread(inttobin(v[i],0),1,8),((i-1)*8)+1)
end
f = bintoint(c,0)
(Throw f into persistent data via dset)
To adjust this for other equal bit values, replace B and
adjust the amount of items used in the v table:
for i=1,#v do
binins(a,binread(inttobin(v[i]),1,B),((i-1)*B)+1)
end
#v B Max Leftover bits
16-bit 1 16 65535* None left over
15-bit 1 15 32767 1 bit
14-bit 1 14 16383 2 bits
13-bit 1 13 8191 3 bits
12-bit 1 12 4095 4 bits
11-bit 1 11 2047 5 bits
10-bit 1 10 1023 6 bits
9-bit 1 9 511 7 bits
8-bit 2 8 255 None left over
7-bit 2 7 127 2 bits
6-bit 2 6 63 4 bits
5-bit 3 5 31 1 bit
4-bit 4 4 15 None left over
3-bit 5 3 7 1 bit
2-bit 8 2 3 None left over
1-bit 16 1 1 None left over
*Any number past 32767 will be represented as a negative
value counting towards 0.
-- Different size bit values (47 tokens)
d = {}
s = {5,8}
v = {31,255}
c = 1
for i=1,#v do
binins(d,binread(inttobin(v[i],0),1,8),c)
c += s[i]
end
f = bintoint(d)
(Throw f into persistent data via dset)
To adjust this for other values and bit sizes, ensure that:
- s and v have the same amount of items
- the sum of all numbers in s is less than or equal to 16
- the values in v are within the boundaries of the
respective bit count specified in s
============================================================
Version History
PROGRAM TKN BYTE
v1.1.1 161 418
Optimized inttobin function.
v1.1.0 171 435
inttobin and bintoint can now read from and write
to decimal.
v1.0.0 136 377
Initial release.
*Token and byte values based on the functions alone;
they do not factor in the included function test.
MANUAL
v1.1.2
Modified examples for applying code in context with
Pico-8 persistent data to work with PRGM v1.1.1.
v1.1.1
Changed version number system.
v1.1.0
Added explanation of additional test functions,
as well as new decimal option for inttobin and
bintoint.
v1.0.2
Removed mention of empty table generation in the
function summary.
v1.0.1
Added bintoint readouts on binread and binins.
v1.0.0
Initial manual.
|

Changes 21/09/2016
- Player can attack, killing zombies in two hits
- Bugfix: Health bar is now accurate
- Player animations (Attack, Die)
- Zombie animations (Hit, Die)
- Sounds(Music, player jump, player attack, zombie hit, player hit)
Changes 23/09/2016
- Bugfix, after dying, the death animation does not trigger again when hit
- You are given a message and the ability to reset the game after dying
- Torches are now animated
Changes 07/11/2016
- Enemy archers
- Health pickups
- Collectibles (main game objective)
- New Music
- New sounds
Sadly, I haven't added a boss, but this is what I would call the "finished" product, other than perhaps a nice boss fight.






20 comments








