Log In  

@exelyte

Follow
Follow

Not sure where to post this but I'm having issues listing all the permutations of elements in a table in Pico 8 using this code:

output = {}

function permutation(a, n)
    if n == 0 then
         add(output,a)
    else
        for i = 1, n do
            a[i], a[n] = a[n], a[i]                     
            permutation(a, n - 1)
            a[i], a[n] = a[n], a[i]
        end
    end
end
cls()
permutation({"d","z","2"},3,1)

for i=1,#output do
    for j=1,#output[i] do
        print(output[i][j],j*8,i*10)
    end 
end

It just seems to add the table with the the elements in the initial order to the output table, but the output table does end up with the correct number of element tables. that is, trying to find the permutations of a 3 element array yields and output table with length 6.

P#67435 2019-09-09 16:18 ( Edited 2019-09-09 16:49)

Cart [#maze_demo-3#] | Code | 2019-03-21 | License: CC4-BY-NC-SA | Embed

Cart [#maze_demo-2#] | Code | 2019-03-08 | No License | Embed

update 1: Did a lot of work on the maze generation and traversal to leverage 2d array of nodes data structure that holds the maze. Attempting to make some kind of game using a maze.

Player character: You are the spinning blue circle. you have the power to move through walls and teleport enemies to different squares
Thief: The thief starts in the upper left corner of the maze and naively traverses every square regardless of enemies or items. However, when the thief grabs a key his speed dramatically increases.
Goal: Your goal is simply to move the skeletons out of the way of the thief until he finds the key and unlocks the door to a new random maze.
Controls: press Z to select a skeleton you are on, press Z again to teleport that skeleton to your current location. Press X to pass your turn to the thief.

Initial upload: Recursive back tracking maze algorithm implementation for both generation and traversal. Not a game yet, but you can watch that little guy traverse the entire maze.

P#62692 2019-03-08 18:53 ( Edited 2019-03-21 15:29)

Cart [#daggerjump-7#] | Code | 2019-02-05 | License: CC4-BY-NC-SA | Embed
1

2/5/2019
Change some music
redesigned the level

TODO:
figure out how to de-couple the background from the level.
currently the entire level is drawn out in the map space. Need to figure out way to draw the levels in code I think, so I can use the map space for the backgrounds of different levels. Currently only enough map space for 1 level...

1/17/2019
added start screen
redesigned enemy and map layout

1/16/2019:
New parallax background implemented, thanks to this tutorial.
Parallax still kinda buggy i think.

changed UFO shoot sound
added explosions on UFO kill
limited dagger lifespan
added UFO explosion sound
added life bar
added instant death lava

WIP of my first pico-8 dev project. I built this on top of @matthughson's excellent advanced micro platformer with liberal use of the amazing art from kicked-in-teeth's tile sheets and DOM8VERSE's projectile tutorial from pico-8 fanzine #3.

P#60698 2019-01-08 21:59 ( Edited 2019-02-05 16:22)

About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-09-19 01:58 | 0.089s | 4194k | Q:48