GAME JAM: Lilypads

Hey guys! This is my discussion for my game jam entry: Lilypads. I’ll post code here, and I’ll also try to comment on my code, ala Ignatz.

Code link: https://gist.github.com/tarrouye/44c541318700bbe3c687

Description of Wrinkle:

Here’s what I’m working towards so far: a simple game where the goal is to stay alive forever. The controls are simple, you drag around to create a ‘wrinkle’, and you try to keep that wrinkle from colliding with anything.

Day 1 Blog:

I’m starting simple. The first I wanted to nail down was the base controls.


I did this by writing a Wrinkle class. A Wrinkle is a gesture line. You can see the full code in the gist. I’ll run through it below.


The touch code for a Wrinkle:

function Wrinkle:touched(t)
    if t.state == BEGAN then
        self.locked = false
    end
    
    --[1]
    if (#self.points == 0 or vec2(t.x, t.y):dist(self.points[#self.points]) > 15) then
        table.insert(self.points, vec2(t.x, t.y))
        
        table.insert(self.trailing, tween.delay(0.175, function() table.remove(self.points, 1) end))
    end
    --[/1]

    --[2]
    if t.state == ENDED then
        self:lock()
    end
    --[/2]
end

I’ve highlighted the important parts above.

–[1] This part of the code is pretty simple. If the point is far enough from the last one, it adds it to the line. It also starts a tween to remove this point from the line in 0.175 seconds.

–[2] This simply says that when you let go, call the lock function.

The lock function:

function Wrinkle:lock()
    self.locked = true
    self:stopTrail()
end

function Wrinkle:stopTrail()
    for i = #self.trailing, 1, -1 do
        tween.stop(self.trailing[i])
        table.remove(self.trailing, i)
    end
end

Again, fairly simple stuff. It sets the boolean locked to true, and then calls a function which runs through all the tweens and stops them so the line will stop disappearing.


Now the draw code:

function Wrinkle:draw()
    stroke(self.colour) strokeWidth(5) noSmooth()

    --[1]
    if self.locked and #self.points >= 2 then
        local change = (self.points[2] - self.points[1])
        local newPoint = self.points[#self.points] + change
        newPoint.x, newPoint.y = newPoint.x % WIDTH, newPoint.y % HEIGHT
        
        table.insert(self.points, newPoint)
        table.remove(self.points, 1)
    end
    --[/1]

    --[2]
    local long = vec2(WIDTH / 2, HEIGHT / 2)
    for i = 1, #self.points - 1 do
        local p1 = self.points[i]
        local p2 = self.points[i + 1]
        if math.abs(p1.x - p2.x) < long.x and math.abs(p1.y - p2.y) < long.y then
            line(p1.x, p1.y, p2.x, p2.y)
        end
    end
    --[/2]
end

–[1] This handles the moving of the line. This part only runs if the line is locked, which as we saw earlier means you let go. What it does is get the difference between the first two points, add that to the last point, and put that at the end of the line. Then it removes the first point.

What this does is move the line in a repeating pattern so it follows the gesture you made.

This line in particular is interesting: newPoint.x, newPoint.y = newPoint.x % WIDTH, newPoint.y % HEIGHT. % means modulo. This line makes points loop back to zero if they go over WIDTH or HEIGHT, so that the line will stay on screen, looping across.

–[2] This part is a little simpler. It loops through all the points, and draws lines between them if they aren’t too far (so that lines aren’t draw between points looping across the screen).


Thanks for reading, I hope this was all pretty clear.

Day 2:

It’s actually a game now! Objects to avoid, powerups to collect, highscores, etc.

No time to do a breakdown today, sorry, but the gist has been updated and I have a video!

https://www.youtube.com/watch?v=Ew2qiRGq93E

Looking good! I don’t think I’ve seen this gameplay concept before. And to get it to “game” status already on day 2 is impressive.

So you are dragging the line around and trying to avoid the obstacles, that’s a cool idea

Day 3:
Spent most of my day working on Fysuzzles, but I did get a bit of work done on Wrinkle.

I’ve added the basis for a level system, so there will be two modes: Endless (video above), and Levels where you navigate to reach the goal.

Last minute scrap! One day before end of the jam, and I’ve decided I don’t like where Wrinkle is headed. I’ve switched gears.

New game (no name yet) is a simple puzzle game with a real focus on the theme. Animations are everywhere, everything should be fluid and beautiful.

Demo: https://www.dropbox.com/s/u9wrj3rt7t5a4do/GAMJAM.mov?dl=0

I really like the design, looking forward to try it on my ipad as soon as I’ll be home :slight_smile:

Here’s the code: https://gist.github.com/JakAttak/44c541318700bbe3c687

Only includes one level right now (and a level editor), hopefully I’ll have time to make more

The level editor is pretty simple, controls are in parameters menu for changing grid size and exporting, then tap in the grid to cycle through the pieces.

Hi @JakAttak, are you going to go with “smooth puzzle” for the title of this one?

nice?although i dont know how to play

@yojimbo2000, sorry for the late reply, I’m going with Lilypads, as that was where the art was supposed to go (frog jumping between Lilypads)

Love the presentation of this, really beautiful.

It’d be nice to have a few more levels, just to really understand the mechanic of the puzzle mechanism.

I was able to use the level editor to build a level, but I ended up making one that was just really easy. The level that is included was surprisingly hard, before you work out how the lily hopping mechanism works.

Really intriguing and very “indie”. The sort of thing TouchArcade might go for I think.

@yojimbo2000, thanks! Yes, I’m sorry I never got around to making more levels (Last minute switch, work on fysuzzles, life)

Hope to come back to this project eventually