Log In  

Cart [#58020#] | Copy | Code | 2018-10-16 | Link


-- 10-16-18
-- sorry forgot to reset score
-- must earn 1000 points for
-- bonus color + corridor
-- reset
-- added horizontal level
-- try to keep in center for
-- stability in flight
-- added descend ❎ key
-- costs 10-points each frame

-- 10-15-18
-- written (10-15-18) ---------
-- time to code: 2-hours ------
-- scaled down collision check-

I'm going to make some updates and upgrades to this game and also make additions to my "BOMBER" game found HERE:


What with all the FLAPPER and FLAPPY clones floating around, thought I would bring back a good old QBasic game I wrote years ago based on a DOS machine-language one I found called "Helicopter."

This gravity game is considerably more forgiving that really any other single-key gravity games I've seen for PICO.

Run. Wait a moment. Helicopter's engines are fired up, you are auto put in hover mode for a second. You get the audio signal from your onboard computer - and you are ready for flight ! Press "Z" to adjust your altitude.

Unlike other FLAPPY games where you only control the vertical acceleration, this one also controls the horizontal. You tilt forward slightly when accelerating. Remember this so when you start to fall backwards you can compensate and not rush your helicopter too far forward where you can't see the cavern walls.

If you touch the ceiling, your helicopter is damaged and while your score is still increasing, you start to take a nose dive to the ground, eventually hitting, ending your helicopter run.

Press (Z) to start a new game.

As for the graphics of the helicopter itself, Scrub was working with me on this. He sent some of his samples before I finally settled on drawing my own.




We will be working on a bigger project later, once I finish the PAINT program I'm working on. But I did want to get this out to show its entirely possible to have a type of FLAPPY game where both gravity and acceleration are both very smooth.

High-Score is maintained and saved to the board so you can play again later and try to beat your last score, even if you shut down the game completely and load it up again later. An audio signal is also given if you beat your last score.

How high a score can you get ?

P#57988 2018-10-15 16:57 ( Edited 2018-10-16 21:44)


Cart [#57748#] | Copy | Code | 2018-10-09 | Link

Alright. Sometimes to improve on something you have to redo the whole thing from scratch. That's what I did here and with workable results.

Now I know PICO is capable of more keystrokes than the simple Left, Right, Up, Down, (O), and (X).

But for purists who don't want to dabble with 2- or 3-player controls, there is this.

It's very good for what it does. It can read keystrokes, and by that I mean layered. You can be pressing 3-buttons down at a time and it will still recognize a unique 4th. It's that powerful. Let's go over it.

You have one string to get things going called, "KEYTYPE." It's a string and contains 6-characters which tell the state of reading for the keys in this order [Left, Right, Up, Down, (O), and (X). I.E:


You have an additional global variable called KEYTIME. I suggest you leave it at 8 as this is a good number for delays and the delay before showing extended keystrokes.

Each of the 6-characters can be the following.

-- "o" ... off
-- "a" ... arcade
-- "i" ... input mode
-- "m" ... measured
-- "s" ... single key only
-- "r" ... release only
-- "x" ... release+extended
  • "O" The first is OFF, meaning it will not be read or registered at all.

  • "A" The next is arcade. The simplest mode to understand. If you're pressing it at any time it registers immediately, much like BTN().

It's also important to realize that while it uses the global string KEY, the keys you are pressing can be layered. That is, you can press all six keys down at the same time and get back "LRUDAB." And to check to see if any of these keys (or more) are pressed, you use the function KEYIN() as so.

if (keyin("l")) x-=1
if (keyin("r")) x+=1
if (keyin("u")) y-=1
if (keyin("d")) y+=1

So with this, it is indeed possible to move diagonally by holding down two keys simulataneously.

  • "I" The next is a bit more complex. It's designed for inputting data. When you hit this key, it registers once, waits, then registers again, waits, then does a repeat max speed like BTN().

  • "M" This one is measured. That is it is a bit slower than BTN() but consistent. It's useful if you are working with something that has a small scope, say 16 or so elements across. You don't want the slowness of INPUT or BTNP(), but you also don't want the total speed of BTN(). This is between that.

  • "S" Single key is just that. You hit it, it registers once and will not register again until you release the button and hit it again. Useful for places where that single keystroke can cause a problem if more than one was sent at a time.

  • "R" Release only. With this the key is not registered until you RELEASE your finger from the key. It also does not register at all if you hold it down for any appreciable time as a safety measure. You must TAP to get it to work properly.

  • "X" Extended entry. This is just like "R" but now if you hold down that button you get an extended keystroke. These are listed in the table below:
-- "l" left
-- "r" right
-- "u" up
-- "d" down
-- "a" 🅾️
-- "b" ❎
-- "w" held left
-- "e" held right
-- "n" held up
-- "s" held down
-- "o" held 🅾️
-- "x" held ❎
-- "h" held left + right
-- "v" held up + down
-- "+" held 🅾️ + ❎

Only with "X" mode as one of the characters in KEYTYPE can you get the special "W" "E" "N" "S" and "O" and "X" strokes. And to get this keystroke you must hold the key down for a short time.

If you release the held key that created the special stroke, it is sent again. This makes it useful to have a menu that stays up as long as the key is held and can close again once you release the key.

Three new special strokes are also available for ALL modes except Arcade. That is if you hold the left and right key. The up and down key. And the (O) and (X) key. They each return "H" "V" and "+"

And they don't register immediately so as to not be activated in a misfire. You must hold these two keys down for a short time in order for them to register. Any time "H" "V" or "+" is registered, the routine is set for safety to ignore any other keystrokes until all keys are released.

And that's it ! If you set all six keys to "X" then you are capable of having a unique 15-keystrokes read from the default 6-keys.

If you have any questions, please let me know.

Hope This Helps !

P#57749 2018-10-09 14:26 ( Edited 2018-10-13 11:36)


Cart [#57568#] | Copy | Code | 2018-10-05 | Link

Years ago I was with my Dad and the MENSA group watching fireworks. There were people all around, it was busy busy, smells of gunpowder and good food were all around.

Everyone was talking noisily and you can hear car radios playing as some sat on top of their vehicle to get a better look.

Right then though, I worried about something. Strange that I would with all the good things and fun around me.

I went to my sister who was sitting on the grass watching the sky.

"What is it ?" she said.

"Where are all the fireflies ?" I asked her.

"Fireflies ?" She looked up and around. "There's no fireflies here. There's no firework called a 'firefly' that I know of."

I pressed the issue, "No, I don't see any fireflies - at all - anymore. Where have they gone ? Are they all in the arctic now ?"

She smiled, "No, you won't have to travel that far to find them." She took a sip of her soda. Looked around, then said, "Come on. I'll show you some."

With that she took a direction completely away from all the activity. Then she ducked into several bushes and kept on. I was afraid we would get lost but I followed her anyways. The bushes were getting thicker and more tangled when suddenly ...

"We're here." she whispered.

"What ?"

She repeated, "Right here, dummy. Take a look."

Somehow, I don't know how I couldn't even hear the fireworks or noise or anything. Only a few crickets chirping. We were in an opening in a huge bush, enough room for only two people, her and me.

And there they were.


All flitting about and each other, lighting up if they bumped into one another.

For a long time I couldn't say anything. I looked to her and she grinned.

Finally she spoke, "Cities have just about driven them out, but you can still find them - if you can find still and quiet places like these. I know this territory and I've been here before."

We watched a few more minutes. She stood up, "Ready to go ?"

I nodded, "Yeah. And - thanks."

"Sure thing." she smiled, and we went back to where Dad and MENSA was to watch more fireworks.

Now these fireflies have a little bonus. They have what I call the, "Friendship Ring." You can turn it on and off with the (X) key. They love the ring and will stay on it, lighting up to show their interest.

To speed up the fireflies, press the (O) key.

Open source to change rotation speed of fireflies and how many there are.

Big props and thanks go to "Remagamer" who with his code showed me a unique way to move an object, by direction and rotation. You can find his amazing cart HERE:


Be certain to give him a star because that's what makes sharing code really interesting is when someone can understand it and apply what they've learned, extending and commending on that intelligent concept or code.

P#57569 2018-10-05 15:08 ( Edited 2018-10-05 19:46)


Cart [#57398#] | Copy | Code | 2018-10-02 | Link

Sweet and delicious.

No Halloween is complete without the sugary treat, "Candy Corn."

If you check out the code, you'll see its naught but a bunch of colored circles. A variation from earlier QBasic code I wrote, this cart is easy for anyone to see how the candy is made. :)


P#57396 2018-10-02 15:15 ( Edited 2018-10-02 15:27)


Cart [#57362#] | Copy | Code | 2018-10-01 | Link

While I don't have any immediate plans for a mapper myself, a great many of you out there do. And that's construction work that could be made easier with this cart.

For this is not only a mapper creator and editor, it also has an in-board function quite similar to the MAP() routine - with the unique exception instead of reading the mapper memory, it reads a single string which contains the size of the map its edges, bits of other data, and the actual mapper data itself.

use import {image}.png to import your own 256-character tile/sprite set to use in the mapper.

Commands follow:

Hold (Z) key to bypass logo.

If you are creating a new map, you will have a very small input routine active.

Use the LEFT and RIGHT arrow keys to navigate by 1-character.
Use the UP and DOWN arrow keys to navigate by 3-characters.
Press (O) to type that character.
Press (X) or have the key select on "<" to erase the last typed character.
Have the key select on ">" to accept that input.

At this time NAME OF MAP is not being used or even recorded. I just put it there to test the input routine, you can skip it by selecting the ">" key.

In editor, tap (X) to do three things. One, change keyboard mode to four. Nice delays and speed, no increase with repeat. Two is select the tile beneath the cursor. Three is you will have an option of selecting any of the 256-sprites to draw on the map, but the cursor initially starts on the last tile you had highlighted back in the editor.

Press (O) to select that sprite/tile. (X) to cancel.

In editor, tap (O) to plot that tile/sprite.

Use arrow keys to scroll. If you choose an area that is bigger than the screen, it will scroll to reveal it.

Press both LEFT and RIGHT to see a demo of the Map-player. Use arrow keys to navigate. Use this function, DRAWMAP() in your code.

The function DRAWMAP() can be used directly in your own code. These are the arguments for it.

  T ... ( Map itself, a text string created from this program ,
  H ... the horizontal position to plot on the screen ,
  V ... the vertical position to plot on the screen ,
  X ... the size across to plot the map on the screen ,
  Y ... the size down to plot the map on the screen ,
 DX ... the starting position (top-left LEFT corner) of the map contents to draw ,
 DY ... the starting position (top-left TOP corner) of the map contents to draw )

As the actual code does not draw the entire cropped map, only the visible part, it should be plenty fast for you.

Back to the editor, press both (O) and (X) to save your map as a string to the clipboard.
Replace with the MAPP line near the top of the code to both save and continue working on your code.

Feel free to make changes or updates, especially optimizing code, these are always welcome !

If you have any questions or suggestions for improving the code, please let me know !

P#57363 2018-10-01 18:24 ( Edited 2018-10-01 18:31)


Cart [#57192#] | Copy | Code | 2018-09-27 | Link

Simple coding example for Scrub of a scrolling map handled by code instead of internal mapper (thereby freeing space from mapper and extending beyond 128 tiles across).

P#57193 2018-09-27 23:21


Cart [#57232#] | Copy | Code | 2018-09-28 | Link

UPDATED: 09-28-18
Saving all SRAM now. CSTORE() RELOAD()

Despite the setback of not being able to retain all the sprite images with 8192-bytes of data (the full-screen), you can certainly save 4096-bytes and still retain a good 128 of 8x8 pixels sprite data.

In this program, press LEFT to clear the screen.
RIGHT to add a random colored circle in the recorded screen area.
UP to confirm the sprite area is not overwritten (top 128 sprites).
(O) to save off that screen area.
(X) to load it back. Try rebooting and loading only to confirm it is recorded.

Since 4096-bytes is allocated from the Sprite area and is not to be overwritten by other sprites, this method works.

And is still 16 times bigger storage than the default 256-byte or 64-numbers via DGET() and DSET().

A warning red triangle is placed on the sprite sheet to show your limits (Sprite #127), as mentioned above, 128-sprites, and this should be enough for most carts.

Additionally, no mapper, sprite pointers or flags, sound effects, or music values are overwritten. Only the bottom half of the sprite sheet.

Actually I'm not so sure about the mapper. Doesn't it share some of the sprites ? I'm not sure since I rarely use the mapper myself.

Saved data does not have to be pixels, it can be anything you want - up to 4096 bytes.

This program will run correctly and load/save 4096-bytes of external data in:

  • Immediate editor mode
  • Compiled to EXE/Linux/APP
  • Compiled to HTM/JS
  • Run in Pico-8's own Splore
  • Saved to Online
  • Compiled to Offline file
reload cstore proof
P#57179 2018-09-27 16:27 ( Edited 2018-09-28 17:20)


Cart [#56846#] | Copy | Code | 2018-09-18 | Link

As I needed an OVAL drawing routine for the paint cart I'm working on, I was surprised to see how small of code it was required in order to do such an effective one !

Here is the original C source code by roger dahl found in stackoverflow.com :

for(int y=-radius; y<=radius; y++)
    for(int x=-radius; x<=radius; x++)
        if(x*x+y*y <= radius*radius)
            setpixel(origin.x+x, origin.y+y);

Here is my code for Pico-8:

-- lovely oval drawing function
-- converted by dw817
-- original by roger dahl

function oval(h,v,x,y,c)
  x=(x+1)/2 y=(y+1)/2 h-=1-x v-=1-y
  for i=-y,y do
    for j=-x,x do
      if ((j/x)^2+(i/y)^2<1) pset(h+j,v+i,c)



As you can see it's a real plotting monster, but it DOES work, and I checked, it does not draw over any pixels it previously drew, so it's going about as fast as it can I think.

P#56847 2018-09-18 12:03 ( Edited 2018-09-19 21:21)


Cart [#56623#] | Copy | Code | 2018-09-13 | Link

This is a simple graphic library for the user, "Scrub."

We got into a bit of a discussion last night, he wanted to erase the 3x5 font in favor of more sprites available. I told him he could do it with strings. This is a simple library with no compression to keep it basic.

That discussion forum can be found HERE:



Draw any sprites you want on the SPRITE page.

In immediate mode, command mode, type:


Where nn is the number of the sprite you want to convert to a string. Press ENTER.

Then in your source-code, press CTRL-V. Rename the variable from IMG to whatever you like.

To display this string-sprite, anywhere in your code use:


Where xx is x-coordinate, yy is y-coordinate, and tt is the string that got converted. In the case of this example, the string's name is BUNNY. Color 0 registers as transparent so it's suggested you use CLS() at the beginning of your _DRAW() function.

And that's it !

If you have any questions or suggestions, please let me know.

P#56625 2018-09-13 18:15 ( Edited 2018-09-20 13:12)


Cart [#58019#] | Copy | Code | 2018-10-16 | Link


Add tank option to reappear in reverse
Add tank option to go faster than before
Added optional sound effects (see code to disable or press CTRL-M during runtime)

(09-13-18) ... Improved accuracy, should be able to hit tank if on edge of screen now.
(09-12-18) ... Released cart

Back in the early days of Apple ][, Robert C. Clardy and Bill Budge ruled the roost.

Robert C. Clardy for his fantastic INTEGER HIRES and LORES adventure games and Bill Budge for his incredible machine-language games which included, Bomber, as you see the tribute here, but also, Space War, Night Driver, Raster Blaster Pinball, Lunar Lander, and Pinball Construction Set.

He was one of the great pioneers of early video game programmers working directly in the 6502 assembly programming language whereas most other game programmers, myself included, chose to work in the simpler languages of Integer Basic and Applesoft Basic.

Perhaps the one game that struck me the most fascinating as a boy was his 20k machine-language BOMBER game. It was a simple premise. You had one key to press that launched a bomb from your plane that moves from one side of the screen to the next.

What I especially liked was the fact if you watched carefully, and I did, that every single pixel that made up the tank image exploded outward when your bomb contacted the tank. It was a real treat to see as many games back then only dreamed of having fragmentary explosions.

The tank initially started out as half that speed so it was a pretty easy target for the jet. After that, the tank changed speeds which made the game more challenging. That and the tricky curve of the bomb as it starts out slow in its descent and accelerates as it falls.

Here now is my tribute to him and his game, the graphics, mechanics, mathematics, and hopefully physics are very close to what he wrote those many years ago.

With options in the source to change from B&W to color and even add flickering of the sprites which is what his original game had in it.

How many tanks can you hit before the time runs out ?

apple 8-bit 1970 bill_budge particle_explosion
P#56595 2018-09-12 22:46 ( Edited 2018-10-16 19:45)

:: More
About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2018-10-17 03:17 | 0.186s | 1835k | Q:107