Log In  
Follow
TheRoboZ
Follow
Skiddy - the slippery puzzle
by TheRoboZ

Cart #picodraw-0 | 2020-08-27 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
5

Mouse and Keyboard are required!

This is a first release of PicoDraw, the tool I created to draw all backgrounds in my Masters of the Universe carte, in a special compressed format.
It uses a mixture of primitives and tile-maps. Maybe someone else will find it useful too or just contribute to further development.

The reason for its creation is explained in this devlog

Thanks to @JadeLombax for his triangle functions!

Code is messy and the tool is not complete but it's quite usable. According to my plan, this is what left to do:

-import/export from serial channel or at least drag/drop text file to load drawings
-sprite tool
-pset tool
-reload() maps and sprites from other carts
-major code cleanup

End of post has a demo cart decoding the drawing from this video

Instructions

Usually I use it after starting pico from a command prompt window (start c:\users\andrea\pico-8\pico8.exe), so I can see live debug info

Tile maps and sprites must be pre created/imported both in picodraw and your cart!!!

(Tile maps can also be used as a temporary reference for shape drawing, I will post an example soon)

This is the very minimalistic interface, most work is done with key commands

After you select a shape you can hold the left mouse button to drag it around or hold the right mouse button to resize it

Keyboard commands:

Backspace  : delete selected shape
+,-        : change selected shape drawing order
9          : hide/unhide background layer
0          : hide/unhide foreground layer
1,2,3,4,5  : select tool [rectangle,oval,line,map,shape picker]
6          : triangle tool (experimental)
`          : cycle through tools
Tab,Q      : select next/previous shape
B          : switch between background and foreground layer
K          : clone selected shape
L          : move selected shape to other layer
G, Shift+G : cycle selected shape gradient fill
[,]        : cycle selected shape color or cycle drawing color if no shape is selected
C          : open color picker (left mouse button picks current tool or current shape color,
             right button sets background cls() color)
M          : enable/disable background horizontal mirroring (toolbar is blue)
T          : shape mutation (changes between rect, oval and line keeping the existing parameters)
F          : fill mutation (changes between filled or stroked shape)
R          : show/hide 8x8 grid
H          : ghost/unghost all unselected shape (useful when working with a small or gradient-filled shape)
O          : enable/disable omni mode, to move all shape at once (with arrows or mouse) (toolbar is green)
Ctrl+Z     : Undo (unlimited but can run out of memory)
Ctrl+Y     : Redo (unlimited but can run out of memory)
Ctrl+V     : Paste shape data (only way for now to import existing drawing)
UP, DOWN, LEFT, RIGHT: move selected shape by 1 pixel
W,A,S,D: increse/decreas selected shape width and height
Shift+W,A,S,D: when a TILE-MAP is selected, will offset the starting tile position

You can draw 256 shapes on each of the 2 layers, when you reach the limit the toolbar turns purple

This video shows how it works, I use a mixture of mouse/toolbar and keyboard commands, everything is on the background layer except the sun, so it's not mirrored.
When you see additional ovals appear, I am pressing the clone "K" key and then work on the new shape.

After the drawing is done, I quit to the prompt and just Ctrl+V paste the drawing data, it's always copied to the clipboard after every operation and it's automatically escaped/unescaped when you copy it from an editor. Then I reset the cart and just Ctrl+V paste it directly into picodraw, to recreate the drawing and continue working.

This is the output:

,'K…|にᵇ'K…|にK'K★|ねS't❎★てᵇ&Nき★ゅ &Nの★チっ&Nへ★ナそ&Nや★フx&Nき★そ¹#RこUこ⁷#[す]す⁷#dこfこ⁷#jすnす⁶#qさtさ⁶#\け^け\r#xす|す\r#○こ⬇️こ\r#♥し☉し⁷#☉し웃し⁷#🅾️さ◆さ⁷#yけ{け⁷F'QQ|xち'UTxuJ'YXur9

Data format explanation:

First byte encodes the background color, then it's a sequence of shapes, all drawn to the background, 6 bytes per shape,

command byte, and 5 parameters until we reach an F as the command byte, this prompts a layer switch, and all the following shapes (again as a series of 7 bytes) are drawn to the foreground.

Command byte is 1=rect,2=oval,3=line,4=map,6=rectfill,7=ovalfill,8=tri,13=trifill

if command is not map, then parameters in bytes 2 to 6 are x1,y1,x2,y2,and color+gradient packed liek this: color | gradient <<4

if command is map then parameters follow pico-8 map functions (cell_x cell_y sx sy cell_w cell_h)

gradient is an index in a preexisting 16 values table

all x,y values have an offset of 46 and are byte-encoded starting from a value of 32, so the final range is -46 to 174

Decode the output in your cart with the following functions

function do_draw_cmds(commands)
  dither_p = split("32768, 32736, 24544, 24416, 23392, 23391, 23135, 23131, 6747, 6731, 2635, 2571, 523, 521, 9, 1")  
  for i=1,#commands do
    local cmd = commands[i]
    if cmd[7]!=0 and cmd[1] !=4 then
      fillp(-dither_p[cmd[7]] +.5)
    end
    _ENV[split("rect,oval,line,map,select,rectfill,ovalfill,,,,,,trifill")[cmd[1]]](cmd[2],cmd[3],cmd[4],cmd[5],cmd[6],cmd[7])
    fillp()
  end
end

function add_draw_commands(bg_commands,fg_commands,string)
  local cmd_table,dest_table,cmd,c_i = string,bg_commands,{},0
  if (#cmd_table>0) bg_color = ord(cmd_table,1)-32
  for i=2,#cmd_table do
    if c_i==0 and sub(cmd_table,i,i) == "F" then dest_table = fg_commands
    else
      local o = ord(cmd_table,i)
      if c_i==5 then
        add(cmd, o & 15) add(cmd, (o & 240)>>4)
        if (cmd[1] == 4) cmd[6]+=1 cmd[7]+=1
      else
        local ofs = (c_i>0 and c_i<5) and -46 or 0
        add(cmd, o-32+ofs)
      end
        c_i+=1
      if (c_i==6) add(dest_table,cmd) cmd={} c_i=0
    end
  end
end

-- you need the following if you use triangles (I only used trifill in my drawings)

function trifill(x1,y1,x2,y2,c)
  local inc=sgn(y2-y1)
  local fy=y2-y1+inc/2
  for i=inc\2,fy,inc do
    line(x1+.5,y1+i,x1+(x2-x1)*i/fy+.5,y1+i,c)
  end
    line(x1,y1,x2,y2)
end

function tri(x1,y1,x2,y2,c)  
  line(x1,y1,x2,y2,c)
  line(x1,y2,x2,y2,c)
  line(x1,y2,x1,y1,c)
end

--if you use background mirroring you need this and you need a global need_copy to keep track of it, as in the demo code

 --copies the left screen area from start_y to end_y, 
 --lines before ofs_line have a 1 pix offset to the left to avoid double pixels when mirroring
function copy_from_ram(start_y,end_y,ofs_line)
  if need_copy then
    for y=start_y,end_y do
      for x=0,63 do
        local cc, ody = pget(x,y), y<ofs_line and 1 or 0
        pset(126-x,y+ody,cc)
      end
    end

    for y=start_y,end_y do
      memcpy(work_ram + y*32, screen_ram + y*64, 32)
    end
    need_copy = false
  else
    for y=start_y,end_y do
      memcpy(screen_ram + y*64, work_ram + y*32, 32)
    end
  end
end

Check this cart for example code on how to put it all together

Cart #picodraw_test-0 | 2020-08-27 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
5

P#81235 2020-08-27 02:26

Cart #motu-4 | 2020-10-03 | Code ▽ | Embed ▽ | No License
55

The battle for Eternia is in your hands!

Side with He-Man and his allies or Skeletor and his minions in this new take on the classic Barbarian sword fighting game.

Battle 8 levels against increasingly difficult foes or play against a friend.

You have the power!

This Pico-8 cart is bursting with the Power of Grayskull, featuring:

  • 16 Characters
  • 16 combat moves
  • 4 stages
  • 8 difficulty levels
  • 3 game modes
  • A kickass soundtrack

Updated to v1.4 - 2020/10/03

Thanks to @RoundUpGaming suggestions, here's what changed:

  • fixed infinite roll attack so you can't chain them and stuck opponent to the edge of the stage
  • added gore disabling option for kids, no decapitations and no blood.

    This makes the game a bit more challenging because you can't have a sudden victory with the flying chop

I want to remind also that you can disable sprite outlining to play with the original style the game had during development

current stats: tokens 8182 / chars 44437 / compress 99.87

Updated to v1.3 - 2020/09/03

  • fixed losing last fight will restart from first opponent, very sorry about this
  • fixed grayskull bg glitch introduced in last update
    current stats: tokens 8182 / chars 44523 / compress 99.87

Updated to v1.2 - 2020/08/31

  • Fixed some P2 controls still affecting CPU opponent

Updated to v1.1

  • Fixed a bug where if the winning blow caused a character to fall it wouldn't display the winning/losing animations
  • Fixed a minor music mistake
  • The flying neck chop was overpowered so now it only decapitates your opponent if his health is 75% or less

How to play:

Arcade mode is a battle against enemies of increasing difficulty to regain control of Eternia

P1 vs CPU is a 1 round fight with customizable difficulties, characters and stage

P1 vs P2 allows you to fight a friend with your favorite characters

While selecting your character in vs modes, use up and down to select stage and difficulty.

Controls:

Player1: Pad 1 \ arrow keys + Z/N ([O] Button - Attack) + X/M ([X] Button - Defense)

Player2: Pad 2 \ E S D F + W/Left Shift ([O] Button - Attack)+ Q/A ([X] Button - Defense)

Move list:

UP -Jump, RIGHT - move forward, DOWN – crouch, LEFT - move backward,

​ATTACK - Body Chop, RIGHT+ATTACK - Neck Chop, UP + ATTACK - Overhead Chop, LEFT + ATTACK - Sword spin, DOWN + ATTACK - Leg Chop,

​DEFENSE - Protect Body, UP + DEFENSE - Protect Head, RIGHT+ DEFENSE - Headbutt, DOWN + DEFENSE – Leg chop,

​ATTACK + DEFENSE - Flying Neck Chop

Credits

Original artworks and idea: John Henderson

Music:

Programming and gfx: Andrea Baldiraghi

Masters of the Universe and all related characters TM by Mattel Inc.

Barbarian TM by Palace Software Ltd. 1987

Thanks to:

John Henderson - for granting me permission to develop this version of his original idea

FL - for his barbarian archive and source codes: http://barbarian.1987.free.fr

@freds72 Frederic Souchu - for finding and sharing it

@JadeLombax - for his triangle drawing functions

@zep - for pico-8 https://www.lexaloffle.com/pico-8.php

And all pico-8 users for their support and contributions on this game
and on Mortal Cards

Development Stats:

Started on may 29 with the first teaser

35% of the time on picodraw for backgrounds

July 9 – complete graphics foundation and picodraw

Aug – 18 game code completed

Aug 22 - Added Music and released online

About three months, working around three hours per day 5 days a week when possible.

My goal for this game was to experiment and expand upon the sprite techniques I used for mortal card, as that was a simple and quite rushed game, made for a jam, but I felt the same ideas could be used for a proper action game. After starting, I also decided to experiment a bit with this mixed shapes/map tiles backgrounds to try and give the game a “big” look, big animated sprites, full screen , painterly style background. I already thought about a barbarian remake since I remembered the game graphics had a lot of repetition that was suitable to be broken into components, and just a short time later, I found John’s post about his motu idea and that gave me the final push as it made it a bit more original and interesting. While scouting the pico bbs to see if a barbarian remake was already attempted or even done, I found this… post that lead to a treasure trove of info that greatly helped for moves timing, AI and overall game flow, even if the code had to be mostly rewritten from scratch for size reason. Overall I am satisfied with the result even if I feel I made a couple of mistakes in the way I manage frames that lead to unnecessary complexity. I should have finalized the frame set once and for all before starting with the input cope and I could have had a more compact representation and probably save some more tokens and compression space.

To fit everything into a cart I had to give up some additional “flourishes” I had in mind, such as an animated intro and an ending mimicking the cartoon with a character giving some moral lesson.. and pre and post fights vignettes with some text and characters portrait.

I had to simplify a bit the bg animations to save tokens so they are not as refined as while they were just work in progress and I had to cut personalized winning poses for every character. I also planned to have a dramatic “clashing” sometimes when swords collided with a lightning and black and white silhouette, but , while I have the code to draw it, it’s simply too much tokens to fit. I might code a deluxe multicart version in the future, but all these are just decorations and don’t really add much to the game itself.

This is my second full game and the third pico coding experiment I also wanted to try to do a port of an existing game to a system, writing my own tools etc.. as old school-style as possible, as I really love reading about classic game programming but never really did anything at the time. Glad that pico-8 gave me a similar, albeit more comfortable chance to experience something close to it. , it was overall a very fun experience, and I hope you all enjoy playing it as much as I enjoyed coding it.

From this experience, I hope I can get some improves tricks for the next game, which I’ll start after a needed break

I will document and release PicoDraw soon, so it can be improved with the input from other pico users.

P#81037 2020-08-22 08:27 ( Edited 2020-10-03 02:38)

Trying to use shifts instead of multiplication, I noticed an odd thing:

work_ram = 0x4300

printh(work_ram +  2*32) -- result: 17216
printh(work_ram +  2<<5) -- result: 24640  + has higher precedence than shift, is this correct? 
printh(work_ram + (2<<5))-- result: 17216
printh(work_ram |  2*32) -- result: 17216
printh(work_ram |  2<<5) -- result: 17216
printh(work_ram | (2<<5))-- result: 17216

pico-8 version: pico-8_0.2.1b_windows

Am I missing something and this is an intended behavior or there's an operator precedence inconsistency?

P#80287 2020-08-03 02:18 ( Edited 2020-08-03 10:25)

Here are three general-purpose example of my sprite rotation function using tline, one for square sprites (112 tokens), one for rectangular ones(154) and an advanced one with support for scaling and flipping

Cart #tline_sprite_rotation-2 | 2020-08-03 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
6

draw_rotated_rect(x,y,sw_rot,mx,my,w,h)

draw_rotated_tile(x,y,rot,mx,my,w,flip,scale)

It always draw a screen-oriented rectangular area, (centered at x,y) large enough to contain the rotated tiles (from mx,my to mx+w,my+h), and calculates the rotated (sw_rot 0 to 1) tline coordinates and deltas.

The catch is that you need a "clearance-space" around the map part to be rotated, matching the largest side of the sprite or you get some additional map tiles drawn as well, visible in pink in the example. But you can just prepare one rotating area and just swap tiles with mset()

The rectangular one could be improved by recalculating the bounding area at each rotation at the cost of additional tokens.

this line just draw a bounding box to show the exact draw area and is not necessary outside of this example:

rect(x-delta_px,y-delta_px,x+delta_px,y+delta_px,5)

Hopefully someone will improve this further.

P#78451 2020-06-24 05:59 ( Edited 2020-08-03 01:31)

My entry for #rndgame2020 - MORTAL CARDS (Mooooooortal Caaaaaaards!)

Cart #mortal_cards-0 | 2020-05-24 | Code ▽ | Embed ▽ | No License
10

With more powerful characters, more secret moves, more depth, more control and the most advanced pico-digitized graphics around – this card game is worth fighting for!

Mortal Cards challenges you with the ultimate card playing experience…
On a secluded island, six elite fighters have gathered to test their deadly skills.

Each competes with a deck of 15 cards, 5 cards each round, as they battle each other and finally, the 4-armed mutant warrior Goro.

Featuring a digitized graphics, multi-layered backdrops and a pulse-pounding soundtrack.

For the most realistic chop-em-up challenge yet, it’s Mortal Cards. The competition will bow in submission.

HOW TO PLAY:

- Check opponent's next card and react accordingly
- Select with left and right arrow, confirm with "Z" Key (Circle button on pico 8)
- Same moves will cancel each other
- Special moves are un-blockable, some will inflict reduced damage when blocked and others will be parried completely
- Discover all the moves interaction
- If health reaches 0 before all card in a hand are used, you can finish with a Fatality!
P#77103 2020-05-24 04:17 ( Edited 2020-08-23 15:14)

Cart #p_harrier-0 | 2020-05-06 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2

my tweettweetjam4 entry, based on the awesome froggy road by 2darray:

https://itch.io/jam/tweettweetjam/rate/331076

It's a pacifist endless space-harrier demake for pico-8, you can;t shoot but must avoid ground obstacles and projectiles (from invisible enemies!)

I'm having problems uploading it to itch.io, so I'll post it here for now

559 chars, here's source code:

x=64u=127z=0q=0h=0n=16y=x
d=0r,g,w=rnd,circfill,x::::flip()cls(1)b=btn()
k=6((b\2)%2-b%2)x+=k;y=mid(n,y+6((b\8)%2-(b\4)%2),u)h+=.4if(z-h<1)z+=1
if(x<9or x>=u)q+=k/4x-=k
for b=z+n,z-1,-1 do
srand(b)p=(b-h+2)/24m=6+r(9)rectfill(0,w+9/p,u,u,9+b%2)for i=1,r(5)do
for v=0,1 do
for j=v,1 do
t=(im4+j+r()-q)%(200-uv)-w
o=p
(1+.5v)-1/(w-nv)k=t/o+w
l=v(r(n)-13)+5t=l/o+w
o=1/o
v
=2t-=nv
if(o>v)g(k,t,o,5+v)g(x,y-4
v,6-v,8+v)
if(z-d>2 and o>8-v and abs(x-k)<o+4 and abs(y-t)<o+6) goto d
end;end;end;end;goto
::d::d=z
?"❎get ready",2,2
if(btn(5))goto _
goto d

P#75965 2020-05-06 14:24

Hello, this is the pico-port of our Windows Store game: Skiddy, the slippery puzzle.

Cart #bbp_skiddy-1 | 2020-04-04 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
15

Help skiddies leave a level by sliding them around all together and using the available obstacles to your advantage.
110 levels with different completion medals (explained in the tutorial).
Can you get them all?

It was a lot of fun to write this lean version for this wonderful fantasy console.
I only cut some bonus levels and hard mode to fit in the .png cart compression limit.
You can erase your progress from the pause menu.

Thanks to zep for his font and to the community for the awesome learning resources

UPDATE V 1.01

  • fixed a crashing bug after tutorial
  • cosmetic and music fixes

Game design by Christian "CH" Costanza, original programming and PICO-8 version by Andrea "TheRoboZ" Baldiraghi

Hope you'll enjoy it!

P#74434 2020-04-03 03:37 ( Edited 2020-04-04 14:25)

Follow Lexaloffle:        
Generated 2020-10-22 12:18 | 0.250s | 2097k | Q:117