Log In  

@dw817

Follow
Follow

Just another mad coder.

We�re all mad. I�m mad. You�re mad, you must be - or you wouldn't have come here.

Cart [#wijagabufi-0#] | Code | 2019-08-18 | No License | Embed

I was reading earlier about the Fisher-Yates Shuffle method and - well, I'm a little confused. What is the purpose of its complexity ?

I mean if you just want to shuffle a deck of cards, for instance, you can do so in code as simple as this:

-- simple card shuffler
-- written by dw817

-- initialize variables
deck={}
rank="a23456789tjqk"
suit="schd"

-- build sorted deck
for i=0,3 do
  for j=0,12 do
    deck[j+i*13]=sub(rank,j+1,j+1)..sub(suit,i+1,i+1)
  end
end

::again::

-- display current deck
cls()
for i=0,3 do
  for j=0,12 do
    print(deck[j+i*13],j*10,i*8,13)
  end
end
print("press a key to shuffle",0,64,7)

repeat
  flip()
until btnp(🅾️)

-- shuffle that deck
for i=0,51 do
  r=flr(rnd()*52)
  deck[i],deck[r]=deck[r],deck[i]
end

goto again

In the Fisher-Yates method you are expected to use a technique that involves saving every single element that was chosen so it will not be chosen again.

What if any are the advantages of using a shuffle such as this based on a simple single-array index-swap as seen above ?

Failing that, what is YOUR method for shuffling items in an array that satisfy you they are properly scrambled ?

P#66748 2019-08-18 00:21 ( Edited 2019-08-18 00:23)

I was curious to know if it was possible to recode the key to pause a cart during runtime. That is, directly in the source-code itself.

If you go to make a program that asks your name and reads the real keyboard via poke 24365,1, if you hit letter "P" it will pause with an interrupt menu. Is there some way, in code, poke or otherwise, to reconfigure the pause key to something like "ESC" or backwards apostrophe "`" ?

How can this be done ?

P#66733 2019-08-17 17:25

Cart [#paziwerize-0#] | Code | 2019-08-13 | No License | Embed

While there is no true PCOPY() command yet for Pico-8, you can certainly simulate having 3-extra virtual pages that will cost you no tiles, no mapper, and even no array space - if you are content to use the resolution of 64x64. In this two new commands are introduced. PCOPY() which will copy a page number from 0 to 3 back to a different page number 0 to 3 where zero is the display page.

It uses MEMCPY() so it should be fast enough.
Changed to use PGET() as apparently memcpy() does not work incrementally.

Doing so you can create images on the other three pages and recall them anytime you want.

You plot pixels using the PST() command where the first argument is page # (0-3), then x-coordinate, then y-coordinate, then color.

And there you have it !

See sourcecode for details. (Added debug option to see all activity)

HOPE THIS HELPS !

P#66653 2019-08-13 18:34 ( Edited 2019-08-13 19:18)

Cart [#wadesupuso-0#] | Code | 2019-08-10 | License: CC4-BY-NC-SA | Embed

If you want to be able to record the screen and use it as a static image for your games, you can do so fairly easily as long as you don't need more than 128- 8x8 graphic characters and don't need the mapper space at all.

With this out of the way you can use

memcpy(4096,24576,8192)

to record the screen, and

memcpy(24576,4096,8192)

to recover the screen. See the source code for the cart above for the code to do so.

This is useful if you are doing more than just a few simple images that can be redrawn, especially if they are elements that are randomly placed. Using memcpy() will be a lot faster and not require you to use arrays to redraw everything exactly like it was. You might even be able to use this method in your current and future projects.

Now I remember QBasic had this good command called PCOPY() which would page copy any graphics you had up to 16-pages via a number 0-15 so it would be

PCOPY(orig,dest)

. Perhaps in the future PICO-8 will have this ability ?

HOPE THIS HELPS !

P#66525 2019-08-10 23:26 ( Edited 2019-08-10 23:28)

Cart [#simple_mouse-0#] | Code | 2019-08-01 | License: CC4-BY-NC-SA | Embed
1

For those learning PICO-8, you may have heard that you can write carts that access the hardware mouse. While the information to do this is not readily apparent, I put together this simple demonstration program with remarks to show how you can do it by reading the position and both buttons of the device.

-- simple introduction to
-- using stat(32,33,34)
-- for reading the mouse
-- by dw817 -- (08-01-19)
--
-- poke(24365,1)
-- enables keyboard + mouse
--
-- stat(32) mouse-x position
-- stat(33) mouse-y position
-- stat(34) =1 if left button
-- stat(34) =2 if right button
-- stat(34) =3 both buttons
--
-- flip() updates the screen

cls()
poke(24365,1) -- enable mouse

c=7
repeat
  color(7)

-- if right-button pressed,
-- change plotting color

  if stat(34)==2 then
    c=c+1
    if (c==16) c=1

-- if both buttons pressed,
-- clear the screen

  elseif stat(34)==3 then
    cls()
  end

-- read x+y position of mouse

  x=stat(32) y=stat(33)

-- if left button pressed,
-- draw on screen

  if stat(34)==1 then
    if ox!=nil then
      line(ox,oy,x,y,c)
    end
    ox=x oy=y
  else
    ox=nil
  end

  p=pget(x,y)
  pset(x,y,c)
  flip()
  pset(x,y,p)

-- loop until press [esc]

until forever

Those who want to reword this OOPS are welcome to.

Hope This Helps !

P#66295 2019-08-01 20:09 ( Edited 2019-08-01 20:12)

For you new people at PICO-8 and even some of you veterans, you may or may not be aware that you can create a BATCH file to run PICO-8 with very precise settings. Here is the one I use:

CONTENTS OF P8.BAT

@run-pico8.exe -gif_len 120 -windowed 1 -width 692 -height 650 -draw_rect 10,5,672,640 -sound 64 -music 64 -pixel_perfect 0 -software_blit 1 -desktop c:\david\games\pico-8\pico-8_win32\roms\_snaps -home c:\david\games\pico-8\pico-8_win32

You can use this as a SHORTCUT too but it is too long, I think a Windows shortcut only allows 64-characters. So if you can, a BATCH file will work just as well.

Modify to your liking and - Hope This Helps !

P#66252 2019-07-31 18:45

Cart [#fast_256_colors-0#] | Code | 2019-07-31 | License: CC4-BY-NC-SA | Embed
3

-- 256-colors rehashed
-- i think this is as fast as
-- i can get the code.
-- you will notice that the
-- loop only moves a section
-- of memory per frame now.

mode=0
p=0
cls()

function _update60()
  p=1-p
  if mode==0 or mode==1 then
    sfx(0) -- confirm drawing
    fillp(23130)
    if(p>0)fillp(-23131)
    for i=0,15 do
      for j=0,7 do
       rectfill(i*8,j*8,i*8+7,j*8+7,i+j*16)
      end
    end
    if mode==0 then
      memcpy(0,24576,4096)
      mode=1
    elseif mode==1 then
      memcpy(4096,24576,4096)
      mode=2
    end
  else
    if p==0 then
      memcpy(24576,0,4096)
    else
      memcpy(24576,4096,4096)
    end
  end
end

This is a puzzle. If you let it run for about 10-seconds, it DOES clear up and show you a near flawless 256-colors using memory swap of two half-screens - but it doesn't stay. After another 10-seconds it garbles, then fixes itself again. But does not stay.

I had hoped by removing the loop for redrawing the colors and writing a loop of memory moves only would speed it up, but apparently it still can't perfectly synchronize.

I noticed online (running in an internet window) it seems to run better with less flicker, so something good is happening there.

Can some Coding Wizard figure out how to get this to run flawlessly (in IDE and as EXE) each time with no period of it messing up ? I think this could be of use to others as it would mean more colors for opening logos to PICO-8 carts.

P#66233 2019-07-31 03:56 ( Edited 2019-07-31 03:59)

Cart [#the_upside-0#] | Code | 2019-07-31 | License: CC4-BY-NC-SA | Embed

cls()

print"mary jane's buster browns"

-- 0=using memcpy()
-- 1=using standard array
kind=1

if kind==0 then

memcpy(0,24576,320)
color(0)
rectfill(0,0,127,5)
color(7)
sspr(0,0,128,5,0,0,128,5,true,true)
reload(0,0,320)
sspr(0,0,8,8,0,0,8,8)
print("",0,24)
stop()

end

rev={}

for i=0,4 do
  rev[i]={}
  for j=0,127 do
    rev[i][j]=pget(j,i)
  end
end
for i=0,4 do
  for j=0,127 do
    pset(127-j,4-i,rev[i][j])
  end
end
rev=nil
spr(0,0)
print("",0,24)

What makes programming interesting is the many different ways in which you can approach a problem.

In this case, I wanted to be able to take a normal sentence and display it upside-down. Not mirrored, not inverted, but totally reversed.

There are 2 methods shown here on how to accomplish this each with their advantages and disadvantages.

I think the 1st method is a variation of some code I saw a year or so ago, so I can't claim credit to it - but I do understand how it works.

The 2nd method is brute force. Likely this method would work in any programming language, but likely also specifically for PICO-8 there is a better way to do it.

The red triangle shows that the sprite area is not corrupt (upon exit) as the first method uses this space for temporary storage of the image to be flipped upside - and the NIL is (hopefully) erasing the array that was temporarily used.

How about you ? Do you know of an easier way to code this effect ?

P#66231 2019-07-31 02:47 ( Edited 2019-07-31 02:59)

I'm trying to understand PICO-8's method of NOT seeding a random number, that is, I want to return back to the original seed after I have seeded a number

cls()
z=rnd()
srand(1)
?""
?"forced seed"
?rnd()
?rnd()
?""
?"reset to random seed"
srand(z)
?rnd()
?rnd()

The only way I know how to do it is this. Get a random number to begin with. Seed the number I want, get the values for this forced seed, then return back by seeding with the initial random number. But isn't there a way to reset the SRAND itself ?

In Blitz for instance, you seed (-1) to return it back to normal non-seeded random numbers, but that does not work here.

P#66228 2019-07-31 00:44 ( Edited 2019-07-31 00:49)

Hello, I am back for a bit, maybe longer, depending on circumstances. Mostly I am programming in BlitzMAX though.

However, I have since come across a program that lets you run LUA in the Pocket Sony Playstation device.

http://www.luaplayer.org/

Since PICO-8 is LUA, is it possible to run PICO-8 on PSP then, as an ISO or CSO ?

The emulator PPSSPP which runs PSP flawlessly is for Android, Windows, iOS, macOS, Blackberry, Meego/Harmattan, Symbian, Pandora, and Linux.

https://www.ppsspp.org/downloads.html

One major advantage of running PICO-8 on the PSP is with PPSSPP you can state-save and state-load. That will definitely be helpful to gamers.

As the resolution of the PSP is 480x272, the screen of 128x128 could be scaled and dithered to 272x272 or 362x272 for a 4x3 proportion.

And it would look great.
So how about it, can it be done ?
Can you do it ?

P#66220 2019-07-30 17:56 ( Edited 2019-07-31 00:48)

Cart [#59148#] | Code | 2018-11-18 | No License | Embed
2

This is much along the same lines as Gembit's remarkable game, "Eternal Tower" HERE:

https://www.lexaloffle.com/bbs/?tid=32173

and Polyphonic's random map generator HERE:

https://www.lexaloffle.com/bbs/?tid=32237

I've always wanted to write the code to a cavern maker where literally each wall is randomly placed and then checked to ensure that the areas around it can be reached.

And now you can ! Guarantees that all points can be reached despite the placement of the walls.

Change DEBUG in beginning to:
0 = Only draw completion
1 = Show the walls being drawn (default)
2 = Show the scanning process for each wall

Running into a bug, let me leave the stairs off for now. Should still run fine.
Got it fixed, should be alright now.

The randomly placed stairs leading up and down are considered FLOOR. That is, if you touch them, you can decide to take them or not. If I try to treat them as walls, they can get stuck in other walls.

Now my question is, can someone optimize this code so it runs considerably faster ?

Thanks, and enjoy !

P#59134 2018-11-18 12:37 ( Edited 2018-11-18 19:19)

Cart [#58876#] | Code | 2018-11-08 | No License | Embed
6

UPDATED 11-08-18 (11:45am)

Years ago when I started writing business software for the IBM, I rarely ever used the mouse, thinking it to be slow and cumbersome. And as such, I would often write a little sparkle routine should you ever press down the button and drag it across the screen. And back then screens were 640x480 so the glitter was really quite pretty at its tiny size.

I never actually sat down just to write this glitter method all by itself, until now.

The code I wrote years ago would sparkle where the mouse is when the button was pressed, then fade, showing the business app beneath. This particular version is actually one you can draw pictures in with. Young kids and those young at heart might really enjoy doing this.

Use the mouse, press the LEFT button to draw a "glitterific" line or plot.

To test it, try writing the first 4-letters of your name, or maybe a symbol like a heart or diamond.

Press (X) to animate the glitter.
Hold (O) to slowly erase the glitter so you can start a new picture.

Change DEBUG=0 to turn off the number counters at the top.

If you like, post some of your own glitterific pictures to show the world.

Enjoy !


Below is original version:

Cart [#58874#] | Code | 2018-11-08 | No License | Embed
6

P#58875 2018-11-08 12:07 ( Edited 2018-11-11 03:31)

Cart [#58730#] | Code | 2018-11-03 | No License | Embed

Scrub and me were just messing around, taking a bit of a break from Paint. He thought it would be interesting for us to write a topview Minecraft in Pico. I took it to mean it would be on a dot level and wrote some code to randomly create colors on the screen, bricks to build with.

But when you take out the colors and mirror the screen, you get a very nice Rorschach Test image.

https://en.wikipedia.org/wiki/Rorschach_test

NOTE: Every test picture has exactly 1001 pixels, no more, no less ! (or 2002 if you count the mirror).

What do you see ?

Post some of your favorites if you like and tell us what you think it is !

P#58731 2018-11-03 17:02 ( Edited 2018-11-05 17:44)

Because 7 ate 9.

No, seriously, why is color #6 so close to color #7 ?

I mean, if you look at the decimal values for the three colors of 5, 6, and 7, you have:

N .. Red . Grn . Blu
05 . 095   087   079
06 . 194   195   199
07 . 255   255   255

You can calculate what color #6 should be based on taking each of the color guns and subtracting the difference from 7 and 5 adding the division by 2.

You would get:

N .. Red . Grn . Blu
05 . 095   087   079
06 . 175   171   167
07 . 255   255   255

So why the disparity ? And why are "gray" not matched all across the board ? If you median them out, (adding the 3 together and dividing by 3), you would have:

N .. Red . Grn . Blu
05 . 087   087   087
06 . 171   171   171
07 . 255   255   255

So why the current color disparity between grays ?

P#58722 2018-11-03 15:56 ( Edited 2018-11-04 20:09)

Very simple request really.

Wanted to know if there was a way to get the white noise in PICO to sound as deep as this.

https://youtu.be/qu7nnOxQmCQ

And if not, can future PICO please ?

Also add optional instruments, use MIDI, which has 127.

So it should be possible to get some music like THIS, with the wind effect:

https://youtu.be/BMKKNFCmj7I

I know PICO is limited, but that music you are hearing now is from SNES which came out in 1990 so that's 28-years ago. Surely we can achieve at least the same level as SNES without affecting current code, SFX, or MUSIC.

P#58420 2018-10-25 16:08 ( Edited 2018-10-26 04:29)

Hello:

I recently came across this link trying to find a particular cart from PICO.

It's interesting in the fact it shows that in other programming languages capable of directly accessing the internet, you can load up PICO source code and elements.

https://www.lexaloffle.com/bbs/snippet.php?cart_id=57568&src=0

-- "fireflies" (10-05-18) ----- -- written by dw817 ----------- -- \138 standard pico-8 license - -- big props to remagamer for - -- human movement method ------ s=16 -- ^ speed of rotation -- lower = faster -- higher = slower n=128 -- ^ number of fireflies ring,ok,z,t,a,x,y=0,0,0,{},{},{},{} for i=0,n-1 do t[i]=0 x[i]=rnd()*128 y[i]=rnd()*128 a[i]=rnd()*360 end cls() repeat cls() if ring==1 then circ(64,64,8,2) circ(64,64,16) circ(64,64,24) end for i=0,n-1 do c=1 if t[i]>0 then t[i]-=1 c=10 if t[i]<4 then c=4 elseif t[i]<8 then c=9 end end pset(x[i],y[i],c) a[i]+=(rnd()*2)-1 h=x[i] v=y[i] x[i]+=cos(a[i]/s) y[i]+=sin(a[i]/s) ok=0 if pget(x[i],y[i])>0 and (abs(flr(x[i])-flr(h))>=1 or abs(flr(y[i])-flr(v))>=1) then ok=1 end if x[i]<0 or x[i]>127 or y[i]<0 or y[i]>127 or ok==1 then if (ok==0) a[i]=rnd()*360 x[i]=h y[i]=v if (ok==1) t[i]=16 end if (x[i]<0) x[i]=0 if (x[i]>127) x[i]=127 if (y[i]<0) y[i]=0 if (y[i]>127) y[i]=127 end if (btnp(5)) ring=1-ring if (btn(4)==false) flip() until forever 

Making a change to the address you can use:

https://www.lexaloffle.com/bbs/snippet.php?cart_id=57568

to return:

[[email protected]]89504e470d0a1a0a0000000d49484452000000a0000000cd08060000003fa57ba90000120a494441547801ed9d4f6c24e959c69fe7fd2ac8dca2c84891629010bd1bc30e5987dd830fa3b04873e0102d3de1b2121634c8c01cf6c809bc238b78034239ce6144ace0283ee4040e9b0387390cab1ce61016332cbb4eb62321b044243cca268ac44ae9fa5e18be2a4fb95ddd5ddd5dd555d5fd3e92dd55dddfdff7fdbdcf7be5eeee1da43a3c3a1a5cbe2c990810240040557559ef39eaee24c31300855e8d011d9cc68c8185c465b7d78bd2e7cb87c3a3a3c16e6fa7920d85a40715ea9377a1872a92183880319d42e32aef5d0b7404a894cbbb5f7e4fa1aad705ddbfc8dd2b894f7a7f2144a1d084b53ffcbd3ff898aa570180c3af7d7df0c7bd9d501e15c8ab5e4980577f091f00c44065c19750fa101179f625201947ac98fa6bf005170ef02deafe4edcb3fb87102cf4fede7baf5e3dbcfadddfddc157fee6ab3f0500f7cee37707bbbddfa9cc1e84a42601c8dabe00d4c504e07adbd5c5d9617a7f38b8c400eabfff02db41eefd9dc3cb2ffe2abff2b5afdf7590e8eeaf6d7d6669034080a0800e4e444484a2221acabffa535cee9081af8efb0fef484a7df7d7f0f2cee963540ee06515648220146af5c57fad11a40aed7f51080408842493ff20167afbfcbb2eeefe690c52a5dfbd73fa1844b436d8eded2c361e25e9fee10f7067f793ad3cbb09383c3a86b4f5f0f75f3e043e3cc4fd3baf59265bac5602787fff21f0da0fc24be706ee7ffc9665d2005c9ceeecbf82e8c3df0400fce5fe43dcf9f08165725501bcffe5832b7fa3be1bfe7edcfc227bec1ebc8c1b0fd6f1ef3f69277c9fbff5ca549fd979e95fde7bf6bb51efe3d6cbfb2def7ddcbc850198c270e74ff6ae3a54e63d7dce8ecdfb6ea2eb65e6a5baf90f7756d235bef5e0e1b5e7f4f3f3b75ec1b71e3cbcf65e74bd2c6cd3ae338ba2321619e55c65809d7555d355f79c776e16ae590b615e072c05c0220e36ef7ac3aeb98c204d7a1fe758b3b8679920d5d2828b38e23030f7bf7c90fbdd2490f3e699eb3dfb3efd4c61ca8e9fd43e87c7cebace2c22a2b5c16e6fc7fa9a69e13a3c3aaec6014da65a5bb0c964009a0c4093c900341980269301686a64fea379261f1e1dcf7b7d81875fd9e40b50f3fd4bd97bb7b733dbed654e00f194c2c147b50760e6e48713d4758689fb6e6c76717e7652e5ede7bf7fb436ebed3d7c1900ce77fdba00a80fbbabb71f7b924ae0abf7f6e5b6e0a65cbf32a758f2e4374157abb1a56a0d7ca6e504d064009a4c06a0694501dcd8ecd676813af7363504c0f3b393da2e50e7de266bc1e6b606e0eac8dcd600342d5917683580d612dbdf055a0d60d52d7170d131e2ac05d7a768bd6f413000add51b802b9efc49adde005d62002725dfce68005a9b33b51f407391f6a84cb3687c0b36354f659ac54a03686ddf5a706b2ad960350097a6ed980cc0c669551dd600348735004dabeb9a06a0b9a601685a5d19802603304f1b9b5dcbce0ae4a4b1009e9f9d58c61b06561539b116bcc2eed3846237005bd2f2e7856463b3dbc83b1a801312dc7430276970d1b9bc5f9d4e6700b6b03d95a168bddfe8f3198026037092dade06edce2d0770916d7070d169c45a6d6ffdd6826754b4de2f0db269d75a45b73500a74cc45ea77be56f7ffbc6b5ef46413a38b20e73ad480dbbf1891806eaa03f3959c373a2f5130c2e3a231d7163b3bb322dd7002ca814a22c70838b0e0ed627cf3de83f036e70d101b6bbd8df06807c005715bec601d80427c803ef9993e503941bd8646cf80ccfe3d636001bda02170d5f9570a46b57bd8f01b804edb64a1df44fcc0d0dc0c5b89eb9e17889c1576ff2b36e58b5363617b3cf52015855d0e6816fafd31df9d76408cfcf9ae7b48d6fc155046d16f8b2808c9b5b74dc280857ad1d3702c08dcdee58d026fd5e759b9e06a6ecb869e7aea21ad18227c155267cd3b84c3a765680d2b945dbeba25ab101b820579d15bebd4eb7d4769882350eaec1456725215c5a006771cdc1d1fcae37ab1b46ebfd5c200dc025d16847230121e018fd3e987d07cb7d1f3ce9141a7fd0ff7bee6fbf58787c9bdfa58a0d3636bfb0d00bcdb7dff42d7a5645eb7dec3f7ab7708b1d76c5456b63b3d839e71111ad0d767b3b334d3e3c3a06061fb5d8fdd276f71cf6b75f980abe3c88a69d3f697cd505311a0a400b57d51ae6e1279af7b0832320ea3528203339d307d8ebbc30157879608cfbad4df1a872ed61c9dcc9eb858054a9aa0352d469f63a5dec3f7a77e4d883fe090efa2778a3408b3de89f146ec575025256c18ce4a76d155356407e3aa573a7901eac4f1efbc504ae3ada67db1c756e075c74c594e16e9a3877d90e5996c30dafd1f60e537a0bce06646373be20d71d90329c6a56408a42ba4c2db71400b301393f6b7e9b99c7418a003a0a90325cb0e91d66de8269440b4e0352859b2e83830c2e3a8d8b4759b92a04e0a22aa60d6e5a341ef340330c48b4de6f5c0cb2b99a878f42008eab98aa5c6b9efd9ad0629a04cd3cf12812ef791c75ee163c8b6bcd139022fb150d48ea5265b7b845c6a3ea965b7557ca05b0c9012953a94b8d73ab83fe09dee8cce6f27b9d2e0efae515cc32386a210057292007fd13ec4d00acaa78140574991cb5f4165c7640363627bbcdf098710129025819904e0357d178cc0a689b0c449a5631e76793035e644cd905330d8493c059e5969b0be0aa076418ae51f148c78d0231fdad886bed75bad87ff4eecab5dc6145550152e5a1eb2c9814ae3c08c7b5dcbc3347ebfdd6c7635e3e2a01b06901d97ff42eb03dda999871b722ee350eb622f128b2cf346769b381c82ab4dc494e930664b81557a132c06a73cb1d562900b621208b80abac784c827411806c6c9617ab71f12805c0a6b5dc790292823a0fac79f148d72cea7e838bcec280ca8bc7f95979ed7f1c1f8d6cc155396a0ad7a48239e89f94ea98297845e04bc746ebfd52e3310ea83a0d642600dbd072cb68c545dd70381ea97b4deb7aa3c62e53871956b42a2d77f8cc838bce15971907610ac7f07779f1d8eb74b1bf0dec756efc3fc0838b0e0ed69b1f8fba0c642600db1c9000de09b0dd053019c03ce8c639e2309c45201f1c01fb07cfdcaf498054ad42002e53405220d2f65ab43d66f566ffa4d43367e15b960e5354b2ac2db7a8ab8d73b345c463d622a8221e7518482100ab0c881381c0d149721402145e8999b8f01a3ec33881801090049d80607817000c6f74ee722c20109164f3e47b471cf4dfc2def35dec75ba617d02100711f76caf2bfb8ffa249c93301d2e9c894c7646388f246f4e70f7b9dbd8eb7c016ff64f207080b8646f81730444e81ce19c8373929c18089710d039fcc266177061dd70ad3416e1d67400497cea85df06e5d99d91dc8d127e877397e763f20c48b2b70392bb10c93c87b08fb8e4397c2f40b28f3ccb89309c0b2e396b9a9b242721692160ce09909c49b29393c051088a4b929f594cc2e6976310024f86032501097700a1091c0e0eb17a78f11aab0fdc69323109321da07148a0c6a1d6280e9a569e10508250a853d05f260a500db771e14bef01a880128740c50220e69bdf7f0b7fd17f0b7ffa8bb74115801e4a40e0c3be209c23bc0fb1510f100eea15ce11f4212180429cc0c387b32649f3e188501080e7de2fbdca2f7eff9bf8f347ff0a08e19d021a930a6c3cff2abd2695a8ca38f6886385bf84009e20443dfef37b6f815e20509002f7f4bab1870801a790242efff5fedf82eae1e0e06381830742b94255e0d4834e412a0471029f47ecc3fe88158ae00a610c436ca1496e3c400f0f017c0c4ac89582504f48ac617d0f9002814063c2390fc728bafbd28b3720d4b0a6847a85864b1102510d57a4423da149de4f1f3f06e28153818a085421001502a8868aa32a2002aac7a7366fe3c71767a1a234864a8ab284bd1d4105200a2aa0a2903814ac0a833d09f8f3bf7c1b3fba788f1481f830c753012f203438490ab22654bbf01b1da10c49f35420a405108fb79f7c0f7ff6fc6dfcc6273e8d874fde0fc5260a1fd36908089c10eae194aa40700baf4a271eb1170ae854a84e1940a49049ddbcf1fc6d7cee13bfc22ff5ff4e4581fdbffa1050a508a9a19cf8e38b3315218401609150cc1e4a118110203de1010f8113450c155505d5c153c29c18f01a0c57e900afc1ad54e999ccf370705e85021f834a30ec19ee020dc10c700aa03e89af40090a05e2226c7df633149fc44a1c8098a2843aa588822a60a8687892aa3141e09f4fff0d0e8ceebef4d28bf09e4ccb5b54a050f2a9ab28a809f554813a52c4433df94fa7ff42f1de8b0a6221482a9380a98471e159a014fee4c97743c0c1509d4ae85397550f264157a820d432a89e028738cd9028e81d7ef4dfef539c9210f55406ef05418122244dd3569c38327c001b24e03d050429500d15cbe0fd78fbc97b78fb871fe08de76ee3d73ffe3c1e3ef92e097809870d2d5e144207f11e148588426381b8a7c9f14a157851064b00dee8fc163ef7732ff04b1f9ce01f7ff81e152448121e1421e9553ca008edf6e993aa845c7b454c45da3934244a958ea21e14405542fb241072037a2ae902d40a0a3574271021ceb14041150a944a511532f412847428a8a013aa0ac50777a7aa7828844e112be17e062f7df6069f16b557ff34ba424f0805e2155e41384d8000143e38a90a4f1f9ffe5f87f9d8cfc67fd4db510ae0bd50435054a0f000d5073791c4fe3c058eaa0af0afbf7a0cf1ff0302eabd5044559fd2e095a468ac4a092e0c893d54427ba3863625082eb9f1e957f91fef7f33445b0171c1ece17d58404180ea95c1019236ebd3b60b2534341c1fda625889319898a9facbc200bd0fc6180a8b0a55f50154d2d313aa1e185c74b0bf7d23e9e94107fd932bef79daeb74afcd195c7410adf727ce9d551b9b5d9c9f4d3e5be96b466bd8ededccb4fee1d13188686d30cf02187cb4d0a0d499ac3c20f35404d2a6dfb5b0e60430aaf2f24d81ef1bdd97f1dac977e63e5770b0d12e56b5cbb53907a3248d3edd14553e4e59f8ca5efb3aa0a69503b0ca2a6fba8394594006a0c95ab055aa6925016c7babb322b3166cedd00034990c406b8706a0b5439301680eda82331b802be4a045cebc68480d4053ad8565009aac059b0cc0a5d5c66637f77955d4f43bd702e02283727e7692fbbc2ab034fdceb500584650160171de1e55eedb7458ac052f3859797bac222406600b5a9dc900b45667009a5645dfe8bedc0c00ab6e67d62e17af22317fede43bcd00b0ea7666ed72f15a64ccad059b6a55a5002e7bfb5cf6fbb51ec0656f9fcb7e3f6bc12603d0643200276863b36be73300ebd3f9d9899dcf00345731ad10806d7795aa0ba82d05ba142dd80aa8bd056a009a0c4093016832e56a63b36b009aead3f9d98901685a5e45f3afb0665134d503e06e6fc72268b2166c32004d2603d064009a4c06a0c90034990c40930168321980a6e62a9a67f2e9e9a945d084adad2d734093b56093c90034b54b51590b3dfaf6036cdfbc75e5335559efdb376f5dd96fdcf8ec98e17365d7c9bbc3f0dcbcfdf2e64e3a4fdef871eb8f3bab3960016ddfbc7519c0e1cfbcc464c7e7bd0f8fcd5b6f38794513389cecbc7993d69a749f496be5cdcf82690e5820f8c32e352e6979ae36cdfc22eb8d2a84321c7f1298c30e5c74fc2cfbcffbde7a008b56795e858f8263dac0e43958550e52d40d875b6d9178ccb2ffbcef4b09605ec58e73b549c9ca7394ec7a79bf170df470318c5bbf882b151d3b6efd693b401b45446b83dddece4c934f4f4f973a38a662dadada9a69dee1d131c4c267aa5306a0a95645652df4e8db0fb07df3d695cf5465be6fdfbc3572ffe1f1d9cf51e3d3df8a9e3f3b3efbbba9810e984d4cfa5cf4337d1e7ecf267edc7e45cf5774bde1b587cf66aad901c7b9e2a2e60f8f1f0757d1f5ca985b654728eb7d29001c4ed8b81638ad834ee36859779a06a251e72fe3ec4d7f5f4a07cc4bee3440a673a61d5f14bc4963f2d69bd7d54d5745446b83dddece4c934f4f4f2d82266c6d6dcd34eff0e81862e133d52903d064009a0c4093c90034198026d3421595b5d0ebafbf7ef97cefdebd6befd931a3dec7ad376ecfbcfdca7acfee3d6e3f53031c309b88f4390bdbbd7bf7aebd175d2f0fbeec7a79e3c79da7e8ef2968a3f633f81a0460d61566999bfecdbadef0f84990172982aaee6baac801674d683a779ca34de3c079ad326ffc3c909bfb350cc0bc44a59f69b2871d6e92434d82a72c171a3eef2847cd736dd3ec22a2b5c16e6f67a6c9a7a7a7164113b6b6b6669a7778745c9d039a4cb5b66093a988a23aacd7643a3c3ac66eaf1799039a6a83cf5ab0a956f80c4053adf01980a65ae133004db5c267009a6a850f0064b7d78b0e8f8e2d52a685c377e98006a1a90ef800e0724080f06860a15b2d1180264fa442e0186b1cbe9a4345e07baaff053ada786f88d003e500000010744558744c6f6465504e47003230313130323231e359b6c10000000049454e44ae426082[/[email protected]]

Changed cart to [email protected] so it wouldn't convert.

In any case, using these addresses, it should be possible to develop engines outside of PICO to access externally stored carts directly.

What do you think ?

P#58065 2018-10-17 21:52 ( Edited 2018-10-18 01:52)

Cart [#58068#] | Code | 2018-10-18 | No License | Embed
4

WHAT'S NEW ??

-- written (10-15-18) ---------
-- time to code: 2-hours ------

-- what's new ?? --------------
-- 10-17-18
-- + tricky, got the color of
--   the board to change only
--   if truly achieving 1000
--   pts. can't decrease score
--   to flip it again.
-- + changed the "collision"
--   check to be right ahead of
--   the helicopter instead of
--   below or above - more
--   margin to wiggle in.
-- + fixed the "impossible"
--   corridors. should always
--   be able to fit between no
--   matter how high the level.
-- + added a launch pad for the
--   helicopter to take off
--   from.

-- 10-16-18
-- + 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
-- + scaled down collision
--   check is now in place.

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

https://www.lexaloffle.com/bbs/?pid=56595&tid=31866

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 than 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.

[16x16]

[16x16]

[16x16]

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-11-02 04:13)

Cart [#57748#] | Code | 2018-10-09 | No License | Embed
2

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:

keytype="aaaaaa"

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 15:36)

No it's not.

Have you ever wondered what kind of clock Lexaloffle is using ?

It's been 8-hours since my last post yet I can still bring up the forum and see posts that say to the side my alias and, "Just now."

What gives ?

P#57609 2018-10-06 10:10 ( Edited 2018-10-06 14:14)

Cart [#57568#] | Code | 2018-10-05 | No License | Embed
4

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.

Fireflies.

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:

https://www.lexaloffle.com/bbs/?tid=31995

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 23:46)

View Older Posts
About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-08-18 23:43 | 0.209s | 4194k | Q:173