Two ships enter. One ship sinks!
[1P] [2P] Left + Right S + F : Steer Ship Z Tab : Fire Left Broadside / Select X Q : Fire Right Broadside / Back Up + Down E + D : Navigate Menu
ABOUT THE GAME
This is SINKING SHIPS, a one- or two-player fighting game about naval combat during the Napoleonic Wars, like Star Control meets Wooden Ships & Iron Men. Keep one eye on your enemy and the other on your wind-vane as you angle for the perfect position to unleash your broadside.
- Take command of one of four “authentic” ships—Sloop, Xebec, Brigantine, or Man o’War—each with its own unique advantages and sailing characteristics.
- Learn to sail!* Maneuver against the wind, and hold the weather-gage to defeat your opponent.
- Play against the AI, or sink a friend(ship) in local multiplayer.
- Fight a single engagement, or take on all comers as you vie for the high score in the endless “Survival” mode.
- Attack during the day, or clash by night using the flash of your cannon fire to illuminate your enemy.
*not actual sailing lesson. do not attempt on real boat.
Been working on this one for a couple weeks—hope you guys enjoy. Feel free to post any thoughts / tips / high scores / nautical jargon below.
For a standalone version (Win/OS X/Linux/Raspberry Pi): Sinking Ships on itch.io
- Hold down the Fire button longer before releasing to increase the range of your guns.
- Ships are slightly more vulnerable to attack in the front, and extremely vulnerable in the stern.
- Cannonballs that strike the sides at an oblique angle will do less damage.
- Take note of the sailing curve of your ship (shown on the graph next to its picture in the selection screen), which indicates how the sails will respond to the wind at various angles.
- No ship can sail directly into the wind (but some can sail very close to it).
- In "Survival" mode, you will regain a small amount of armor protection after defeating each enemy ship, proportional to its size.
SLOOP (4 guns)
- highly manueverable
- can sail at nearly any angle to the wind
- very light armor
XEBEC (8 guns)
- fastest on a beam reach (perpendicular to the wind)
- presents small bow+stern target
BRIGANTINE (12 guns)
- good balance of firepower, maneuverability, and sailing response
MAN O' WAR (20 guns)
- devastating broadside at close range
- slow turning and acceleration
- sails poorly into the wind
- fastest speed sailing downwind
code & gfx by Nicholas Musurca
music from Piano Sonata No. 2 (Chopin, 1839), and Heart of Oak (Boyce, 1759)
- @zep, for his 5x6 font used as a starting point
- @dddaaannn, for picotool
- @ultrabrite, for a compact insertion sort
- @freds72, for Baptista's distance approximation, catching an off-by-1 bug
- @morgan3d, for some bitwise tricks
- @nucleartide, for his great PICO-8 mobile template
- and everyone on the Discord for their helpful comments
EDIT: updated demo to include huge optimizations contributed by Felice and ultrabrite in the thread below.
After reading this fascinating article about the Minsky Circle, I started experimenting with the algorithm in Pico-8. In the process, I stumbled upon a method for rasterizing circles that seems to be faster than the native circ() and circfill() functions at larger sizes, and also has a more pleasing look that minimizes low-resolution aliasing.
Demo attached in case anyone finds this useful. Press Z (or whatever key you've bound to button 1) to toggle between the Minsky Circle-based methods and the native Pico-8 draw functions.
--by @musurca and @Felice function minskycirc(x,y,r,c) x,y=x+0.5,y+0.5 local j,k,rat=r,0,1/r poke(0x5f25,c) --set color for i=1,0.785*r do k-=rat*j j+=rat*k pset(x+j,y+k) pset(x+j,y-k) pset(x-j,y+k) pset(x-j,y-k) pset(x+k,y+j) pset(x+k,y-j) pset(x-k,y+j) pset(x-k,y-j) end pset(x,y-r) pset(x,y+r) pset(x-r,y) pset(x+r,y) end -- @musurca, @Felice, and @ultrabrite function minskycircfill(x,y,r,c) x,y=x+0.5,y+0.5 local j,k,rat=r,0,1/r poke(0x5f25,c) --set color for i=1,r*0.786 do k-=rat*j j+=rat*k rectfill(x+j,y+k,x+j,y-k) rectfill(x-j,y+k,x-j,y-k) rectfill(x-k,y-j,x-k,y+j) rectfill(x+k,y-j,x+k,y+j) end rectfill(x,y-r,x,y+r) end
EDIT: changed the rendering style and improved performance. Happy New Year from a surly talking head!
Spend a long night with an uncooperative subject.
EDIT3: round 2 -- with updated algorithms, methodology, and results
EDIT2: added Catatafish's method -- we have a new champion!!
EDIT: added solar's method.
EatMoreCheese's thread about triangle rasterizers got me thinking about the different "trifill" methods that have been posted to the BBS—and so, in the spirit of the holiday season, I wrote a small profiler to pit them against each other in a brutal, winner-takes-all competition.
Methodology: I measure the time it takes for each routine to draw the same table of 300 randomly-generated triangles ten times over. Vertex extents are in the range [-50, 178].
CAVEATS: This is not an "apples-to-apples" comparison, or even apples-to-genetically-modified-oranges. For example, scgrn's method draws n-gons (not just triangles) and creamdog's method draws particularly chunky triangles. For personal edification only—no code-shaming intended!
Round 2: electricgryphon retakes the crown with a blistering ~5600 tris/sec, followed by Catatafish in a close second, and leaving musurca and NuSan tied for third (on average).
Round 1: Catatafish's method takes first place with an absolutely insane ~0.4 secs, followed by the method from the Gryphon 3D engine in second place at a very stable ~0.8 secs.
A lot of interesting discoveries—among them that rectfill() beats rect(), line(), AND memset().
Let me know if you'd like me to change your entry, or add others!
See round 1 here:
**UPDATE v0.21: click n' drag support, analog keyboard control, smaller template, and LOTS of bugfixes
A vector graphics authoring tool for your Pico8 demos, fonts, adventure games, etc. Draw an image, then save it as a highly compressed string which can be shared with other PiCAD users, or else displayed in your own cartridges without using any space in the spritesheet by including the PiCAD API.
To use your PiCAD images in your own cartridges, start with this template API (click Show to see):
-save/load images as compressed strings (saved to picad_string.p8l)
-save to a spritesheet (saved to picad_export.p8)
-paint with a variety of brushes, including pattern/gradient fill, bezier curves, and copy/clone screen rectangles
-mouse & keyboard support
ENTER: open save/load menu
x: show/hide UI
q: show/hide guides
s/f: scroll color
e/d: scroll brush
To load strings into PiCAD, hit ENTER, select "Load..." and paste (Ctrl-V/Apple-V) the string into the Pico8 window. This must be done in the actual Pico8 console as the web player does not support reading from the clipboard.
Tech info: Rather than raw pixel data, PiCAD images are composed of a series of encoded draw operations—like an assembly language for images—which allows them to be stored as highly compressed strings. The format is inspired by the Sierra AGI "PICTURE" specification. Thanks to @dw817 for fast floodfill code.
(PiCAD is a lot more useful when used inside the actual Pico8 console rather than on the web player, which does not support save/load.)
GUIDE TO SETTINGS:
Export CLS Cmds: PiCAD strings generally begin with a "clear screen" opcode. That opcode is omitted from string exports when this setting is OFF. ON by default.
Continue Lines: When ON, lines and bezier curves can be continued relative to the previous operation, which will produce more efficient strings. OFF by default.
Autosave: When ON, saves your work to a string in picad_autosave.p8l after every new brush. OFF by default.
Click n' Drag: Turn ON if you're more comfortable with clicking and dragging to place brushes (rather than clicking and releasing for each operation). OFF by default.
Analog Keyboard: Simulates an analog joypad when using the keyboard instead of the mouse, which should make using PiCAD more pleasant on the PocketCHIP. ON by default.
Pico-8 implementation of Scale2x and Scale3x. Original algorithms by Andrea Mazzoleni
--[[ sind : sprite index sz_x : x size sz_y : y size sx : screen pos x sy : screen pos y alpha: color to make transparent ]]-- function scale2x(sind,sz_x,sz_y,sx,sy,alpha) alpha=alpha or 0 local offx=sind%16 local offy=flr(sind/16) local soffx=offx*8 local soffy=offy*8 local sizex=sz_x-1 local sizey=sz_y-1 local a,b,c,d,e,f,g,h,i, e0,e1,e2,e3,x0,y0 for y=0,sizey do for x=0,sizex do e=sget(soffx+x,soffy+y) a=e b=e c=e d=e f=e g=e h=e i=e if y>0 then b=sget(soffx+x,soffy+y-1) end if y<sizey then h=sget(soffx+x,soffy+y+1) end if x>0 then d=sget(soffx+x-1,soffy+y) if y>0 then a=sget(soffx+x-1,soffy+y-1) end if y<sizey then g=sget(soffx+x-1,soffy+y+1) end end if x<sizex then f=sget(soffx+x+1,soffy+y) if y>0 then c=sget(soffx+x+1,soffy+y-1) end if y<sizey then i=sget(soffx+x+1,soffy+y+1) end end e0=e e1=e e2=e e3=e if b!=h and d!=f then if(d==b) e0=d if(b==f) e1=f if(d==h) e2=d if(h==f) e3=f end --draw x0=sx+x*2 y0=sy+y*2 if(e0!=alpha) pset(x0, y0, e0) if(e1!=alpha) pset(x0+1,y0, e1) if(e2!=alpha) pset(x0, y0+1,e2) if(e3!=alpha) pset(x0+1,y0+1,e3) end end end
--[[ sind : sprite index sz_x : x size sz_y : y size sx : screen pos x sy : screen pos y alpha: color to make transparent ]]-- function scale3x(sind,sz_x,sz_y,sx,sy,alpha) alpha=alpha or 0 local offx=sind%16 local offy=flr(sind/16) local soffx=offx*8 local soffy=offy*8 local sizex=sz_x-1 local sizey=sz_y-1 local a,b,c,d,e,f,g,h,i, e0,e1,e2,e3,e4,e5,e6,e7,e8, x0,y0 for y=0,sizey do for x=0,sizex do e=sget(soffx+x,soffy+y) a=e b=e c=e d=e f=e h=e i=e g=e if y>0 then b=sget(soffx+x,soffy+y-1) end if y<sizey then h=sget(soffx+x,soffy+y+1) end if x>0 then d=sget(soffx+x-1,soffy+y) if y>0 then a=sget(soffx+x-1,soffy+y-1) end if y<sizey then g=sget(soffx+x-1,soffy+y+1) end end if x<sizex then f=sget(soffx+x+1,soffy+y) if y>0 then c=sget(soffx+x+1,soffy+y-1) end if y<sizey then i=sget(soffx+x+1,soffy+y+1) end end e0=e e1=e e2=e e3=e e4=e e5=e e6=e e7=e e8=e if b!=h and d!=f then if(d==b) e0=d if((d==b and e!=c) or (b==f and e!=a)) e1=b if(b==f) e2=f if((d==b and e!=g) or (d==h and e!=a)) e3=d if((b==f and e!=i) or (h==f and e!=c)) e5=f if(d==h) e6=d if((d==h and e!=i) or (h==f and e!=g)) e7=h if(h==f) e8=f end --draw x0=sx+x*3 y0=sy+y*3 if(e0!=alpha) pset(x0, y0, e0) if(e1!=alpha) pset(x0+1,y0, e1) if(e2!=alpha) pset(x0+2,y0, e2) if(e3!=alpha) pset(x0, y0+1,e3) if(e4!=alpha) pset(x0+1,y0+1,e4) if(e5!=alpha) pset(x0+2,y0+1,e5) if(e6!=alpha) pset(x0, y0+2,e6) if(e7!=alpha) pset(x0+1,y0+2,e7) if(e8!=alpha) pset(x0+2,y0+2,e8) end end end
UPDATE: (0.2) Updated the mouse library so that the cursor can be driven by the gamepad OR the mouse at any time, to make the cart compatible with all Pico-8 devices.
I'm cobbling together a UI/mouse library for my own use, and thought it might be useful to others. For now the only widget is a button, but I wrote the API so that it's easy to modify and extend (in theory). Will provide more documentation if there's interest.
This would be a quick "hello world" with the library, for instance:
--button "onclick" callback function hideme(this) this.visible=false end function _init() --enable the mouse and --set the cursor to a 6x6 sprite --at index 0 mouse_init(0,6,6) --create a new parent UI and --make it the active one mainui = ui_make() ui_setactive(mainui) --make a button labeled "hello, world!" --which calls hideme() when clicked. --It will draw at screen position (30,30). --I could also optionally specify a width and height, --but if I leave it out the button will be sized automatically --based on the length of the label text. btn_make(mainui, "hello, world!", hideme, 30, 30) end function _update() --update mouse position and do event callbacks --as needed mouse_update() end function _draw() cls() --print mouse position print(mouse.x.." "..mouse.y,0,0,7) -- draw mouse on top of UI ui_draw() mouse_draw() end
thanks to gamax92 for uncovering this nifty feature...
Wanted to throw something together for p8jam2, so did a spin on the forest-fire cellular automata.
Up/down: adjust probability of new fires
Left/right: adjust probability of tree growth
Button 1: reset probabilities
Button 1+2: reset map
(Warning: you could probably give yourself a seizure by cranking up the probabilities to the max.)
If you're not familiar with forest-fire, the rules are as follows:
1) A burning cell will become an empty cell
2) A tree will start to burn if at least one neighbor is burning
3) A tree ignites with probability f even if no neighbor is burning
4) An empty space fills with a tree with probability p