Giter Site home page Giter Site logo

greggman / rockfall Goto Github PK

View Code? Open in Web Editor NEW
15.0 3.0 2.0 16.18 MB

Rockfall. A game where rocks fall

Home Page: https://greggman.github.io/rockfall/

License: Other

JavaScript 72.74% HTML 5.39% C 21.87%
game games gamedevelopment game-development game-dev boulder-dash boulderdash boulder-dash-game

rockfall's Introduction

RockFall

Live Version

Make your own levels and contribute them here!

See instructions here.

Rules

  • ๐Ÿ™‚ Player: A, S, D, W or โฌ…๏ธ, โžก๏ธ, โฌ†๏ธ, โฌ‡๏ธ to move

  • ๐Ÿงง Exit: Opens when you've collected 'goal' number of diamonds/eggs

  • ๐Ÿ”ณ Open Exit: Completes the level

  • ๐ŸŸซ Dirt: Can be dug

  • โฌœ๏ธ Wall: Unmovable, un-diggable, but explodable

  • ๐ŸŸช Border: Un-explodable

  • ๐ŸŒ‘ Rock: Pushable left or right.

  • ๐Ÿ’Ž Diamond: 100 points

  • ๐Ÿฆ‹ Butterfly: Turns left. If something falls on it or it touches an amoeba ๐Ÿฆ  it explodes into 9 eggs. Deadly to player.

  • ๐Ÿฅš Egg: Worth 10 points, Hatches into Butterfly

  • ๐Ÿ‘พ Guardian: Turns right. If something falls on it explodes into space. Deadly to player.

  • ๐Ÿฆ  Amoeba: Grows. If it reaches 100 Amoeba they all turn to eggs. If it's surrounded so it can't grow they all turn into diamonds.

  • ๐Ÿฆ€ SideWalker: goes only left/right or up/down

  • ๐Ÿชฒ Patroller: only turns when it hits something

  • ๐Ÿšช Door: player can pass through but nothing else.

  • ๐Ÿ’ฃ Bomb: explodes when it falls on anything but dirt or when touched by an enemy.

  • ๐Ÿง Magic Wall: The first time something drops on it it turns on. While on, any rock or egg dropped on it will become a diamond. Any diamond dropped on it will become a rock. Stops after a few seconds.

  • ๐Ÿ”ฅ Fire: Burns dirt. Not dangerous to stand next to but you die if you walk in it. Kills Enemies

  • ๐ŸŽˆ Balloon: Floats up, if it hit's spike โš™๏ธ bursts into diamond.

Rocks, Bombs, Eggs, and Diamonds will fall if there is space below them or if they are sitting on top of another rock, egg, or diamond and there is space for them to fall.

You can restart by clicking in the top left corner or select another level by clicking the name.

Note: You can dig one tile without moving by holding shift.

The first level is random so and there is no real theme so it's just a proof of concept. In fact given it's random it's possible it's impossible to complete. If so click the ๐Ÿ”„ icon to generate a new level. If you get stuck you can kill yourself by clicking the โ˜ ๏ธ icon. Note that having the entrance blocked means you can't do the level but having the exit blocked may mean you can challenge yourself to lure some enemies over there and drop rocks on them to mine a way into the exit ๐Ÿ˜›

A real game would require hand designed or algorithmically generated levels.

Settings

These settings can be set with query parameters

property default description
amoebas 1 number of amoebas
butterflies 5 number of butterflies
diamonds 15 number of diamonds
guards 3 number of guardians
rocks 280 number of rocks
walls 10 number of walls
magicWalls 2 number of magic walls
fire 0 number of fire
balloons 3 number of balloons
bomb 3 number of bombs
sideWalkers 3 number of side walkers
patrollers 3 number of patrollers
maxAmoebas 100 how many amoebas when it turns into eggs
amoebaGrowthRate 200 lower is faster
amoebaMinTicksToGrow 50 Force the amoeba to grow within this many ticks
fireSpreadRate 10 lower is faster
maxFireAge 40 Frames when fire dies (must be less than 63)
magicTime 250 how many ticks the magic walls stay active
tileSize 32 size of tiles (note
scrollRate 0.0125 scroll speed
diamondPoints 100 points for collecting diamond
eggPoints 10 points for collecting egg
dirtPoints 1 points for digging dirt
mapWidth 80 map width in tiles
mapHeight 25 map height in tiles
frameRate 0.1 frame rate in seconds
colorVariation 1 color variation multiplier. Set to 0 for no variation
requiredCount 15 count (eggs + diamonds) needed to open exits
timeLimit 1500 time limit in seconds
maxPushRocks 100000 max rocks that can be pushed
pushTurnsPerRock 1 turns per rock to push (set to 0 for same speed regardless of number of rocks)
minRockPushTurns 1 number of turns until you can start pushing rocks (set to 0 for instant)
canPushWithRocksAbove true can push with rocks above
playerBoundsWidthPercent 0.125 size of window to keep player inside
playerBoundsHeightPercent 0.125 size of window to keep player inside
level 0 level to use (see here)

Examples:

History

In the early 1980s, a game, BoulderDash came out for the Atari 800. My friend, John and I, got addicted and cleared all the levels.

At some point John tried to reproduce the main logic of the game. He did this in a language called Action!. It's pretty incredible to think someone stuck a language compiler and editor in a 16k cartridge!

In any case, John got something working. The code was not all that big. As such, over the years I've ported it several times. I ported it to C at some point. According to the comments that was 1992.

I once ported it to Z80 assembly for the original GameBoy when I was first learning how it works. I ported it to Java for some feature phone around 2003-2004 to bring to a job interview at Namco Japan for their mobile division.

Recently (March 2022) I was going though some old backups and I saw it sitting there and decided it might be fun to port it to JavaScript.

My first attempt was to use emoji and Canvas 2D.

After that I thought it would be fun to use the tilemap shader I wrote for HFT-BoomBoom.

This is the result.

Note: Differences from the original:

In the original, Butterflies explode into diamonds, not eggs. It would probably be best to make a 3rd enemy that explodes into diamonds for the variety but in these random levels it's arguably more fun that butterflies explode into eggs so you can see lots of movement. Also in the original you can only push a single rock. If 2 or more rocks are in a row they can not be pushed.

Design

Currently the first level is just randomly generated.

For this game to be fun really requires well designed levels. The original Atari game had 60 or so levels. Each level had themes, a required number of items to open the exit, and a time limit. In other words, if the level required 40 items then you'd need to collect 40 diamonds or eggs to open the exit and then make it to the exit before the time limit.

The first few levels were mostly just rocks, walls, and diamonds. Some levels had less than the required diamonds but had butterflies so if you dropped rocks on them they'd generate diamonds. Other levels, some diamonds might be surrounded by walls so you need to lure guardians next to the walls and drop rocks on their heads to explode the walls.

Another example was the magic wall. It turns rocks into diamonds but you can only use it once. So, you'd need to dig around and push as many rocks as possible into position and also dig out space below the magic wall so that once you turned it on you could push all the rocks into the magic wall and have them all turn into diamonds.

Yet another example was having the amoeba at the bottom of some level and you'd need to find a way to surround it with rocks so that it turned into diamonds before it grew too big and turned into eggs and then butterflies.

Anyway, all of those are interesting puzzles to solve but they require a level designer. PRs welcome!

Building levels

See instructions here.

Enhancements / Ideas

At the moment I just used the system's emoji for graphics. Ideally, at a minimum, someone would draw custom graphics including animated tiles for the gem spinning, the butterfly flapping, the monsters moving, the amoeba oozing, the magic wall animating, the egg hatching, explosions.

It might also be fun to try to make the graphics appear to not be tile based but actually keep them tile based. Change the shader (or the game logic) to add edge tiles. Add something to the shader to offset moving characters over time. etc...

Add more rules, entities: The number one reason I wrote this was I thought it might be fun to make more types of things. Random simple ideas:

  • Enemies that only go left/right or up/down ๐Ÿฆ€
  • Enemies that only turn when they hit something ๐Ÿชฒ
  • Smart Enemy: Always moves toward you ๐Ÿง 
  • Indistrutable: Just drives around and gets in the way ๐Ÿ—ฟ
  • Enemies that path find
  • Water (can flow left/right and go down, maybe Diamonds float up in water, maybe rocks fall slower) ๐ŸŸฆ
  • Gas (can flow left/right and go up, maybe can light gas on fire)
  • Balloons (float up, opposite of rocks) ๐ŸŽˆ
  • Fire (spreads. Burns dirt) ๐Ÿ”ฅ
  • Bombs (make chain explosions) ๐Ÿ’ฃ
  • Firework: touch it, drop something on it, it ticks then starts a fire? ๐Ÿงจ
  • Cloud: Makes water? ๐ŸŒง๏ธ
  • Freeze enemies for a few seconds when you touch it ๐Ÿšฆ ๐Ÿ”ดโญ•๏ธ
  • Bomberman Bombs (bombs that fill space and eat just one edge of dirt)
  • Ice Rocks (rocks that when pushed continue left/right)
  • Ice Bombs (bombs that when pushed continue left/right)
  • Diggers (enemies that dig dirt)
  • Diamond eaters (enemies that eat diamonds)
  • Diamond makers (enemies that eat rocks and hatch diamonds)
  • Feed - touch it and for the next N seconds you drop (dirt, monster food)
  • Doors - you can go through, monster can't ๐Ÿšช
  • Doors that open and close on pass through. In other words you can always go through but enemies can't unless you leave them open.
  • Rotation (the GPU renderer can draw at any angle so, turn 45 degrees and have rocks slide. Or turn 90, 180, 270, and down is a new direction. this could be random, or time based, or there could be an object you touch to rotate or 4 objects to orient or drop a rock on etc...)

To be honest I think an actual shipping game would be best with a few core features and then iterating on puzzles using those limited features. Otherwise the player isn't given a change to master each feature. Still, experimenting could help find the most interesting features and then you could choose the top 6-10 and build levels from those

PRs and ideas welcome.

Legal

I have no idea what the legal implications are. AFAICT, Game Mechanics can not be copyrighted but of course I am not a lawyer. Further, the game is 38yrs old so there are certainly no valid patents. And of course, this is just derived. No idea how the original game runs. In any case though, use at your own risk.

LICENSE

The game is MIT, the levels are licensed by their respective creators. The license and the creator detailed in the level file itself. If there is no license in the level file then they are CC-BY.

To be clear, you have my permission to publish a commercial game based on this code but make sure to provide attribution as required and make sure you only include levels that have a compatible license. (CC-BY, CC-BY-ND, CC0)

Also, I'd love to know about it!

rockfall's People

Contributors

greggman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rockfall's Issues

Split Screen Multi-Player

The code already handles 2 players. The tiler can draw multiple sections of the map. Maybe we could split the screen into N pieces (not sure what if any limit for N)

Fix Scroll Speed

Because game runs at 10fps and scroll speed is set to 10% that means for each of the 6 displayed frames of a game frame the screen scrolls at 6 different rates.

In other words, lets say the screen needs to scroll 32 pixels (one tile)

It might scroll 32 * 0.1 pixels on frame 1 or 3.2px to position 3.2
Then it would scroll 28.8 * 0.1 pixels on frame 2 to 6.08
Then it would scroll 25.92 * 0.1 pixels on frame 3 to 8.672
As you can see each frame is slower but then jumps up when the player moves further
At frame 6 a game frame ticks and now it's target is 64 pixels.

This stutter is noticeable.

A simple solution is probably just a max velocity of tilesSize / frameRate

Fix PC version

Probably need to draw characters with center/middle alignment?

Try to add smooth motion

The game is tile based but maybe we could make tiles slide by adding some extra state that the shader can use to draw

Use a seeded random?

That way you could provide the seed and get the same level? Kind of scary in that if you add anything it will change the outcome. Meaning, adding this would add the responsibility that changing the code and/or adding a new feature does not change what level is generated for a given seed.

Add Exit

Let player actually complete level

Go fullscreen on Android?

seem like I don't want to go fullscreen on desktop (though maybe an icon to do it since most users probably don't know they can do it themselves).

Should I force landscape orientation on android?

Should I force the game to landscape period? I can't force it landscape on iOS but I can detect if the screen is in landscape or portrait and if portrait then draw the screen rotated 90 degrees to tell users to turn the screen

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.