Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

A Notebook & a Platformer

A topic by Valdus created Jun 11, 2024 Views: 253 Replies: 4
Viewing posts 1 to 2

I was playing with Decker, trying to create a notebook in the Zettenkasten tradition (using a template and making pages and pages of thought) when I realized I can add cool pictures which I don't really do on my wiki)- when my 9 year old son looked over my shoulder and asked...

"Could I make a platformer game with that?"

I told him I think so, but I have NO idea where to begin to do something like Mario running through a screen. Any suggestions? All I saw was the Sukoban deck. 

PS: Though just beginning, my notebook is coming out pretty cool... here is the basic template I use.



Developer

Maybe!

Decker is designed to work equally well on desktops, in web browsers, and on multitouch devices that don't necessarily have a keyboard, so input events are limited to a common intersection between the capabilities of all these devices. You can't obtain raw "keyup"/"keydown" events, but it is possible to capture arrow key presses (or their equivalent "Nav Gesture" directional swipes on a touch device) through the "navigate[]" event, and you can assign alphanumeric keyboard keys as shortcuts for clicking on buttons. General mouse input is available through the Pointer interface and the "click[]", "drag[]" and "release[]" events provided by Canvas widgets, though since it's trying to represent the intersection between mice and touch gestures, input is limited to a single button.

Sokoban is a good fit for the constraints of Decker's keyboard input, since everything is turn-based. A classical Nethack-esque roguelike might also work well, or many types of puzzle game. Some action games could also work: in Pac-Man or the puzzle-platformer Lode Runner, the player character typically continues moving in one direction until a player provides a new key input. You could also design action games purely around pointer input; I could imagine something like Joust using the mouse to control the player's direction and clicking to make your mount jump and flap.

Making a platformer is a pretty complicated project no matter how you slice it, let alone one with good "gamefeel", but here's a very basic scrap of a starting-point: a card with an Animated Canvas as a display, a field to store a JSON representation of the game state (player position and velocity, to begin with; you can make this field invisible when you aren't debugging), and a card-level view[] handler that updates the state and redraws the canvas at 60FPS based on the pointer:


You can copy and paste this snippet below to try it yourself:

%%CRD0{"c":{"name":"home","script":"on view do\n st:\"%j\" parse state.text\n \n grounded:!screen.size[1]>st.pos[1]\n relpos:pointer.pos-(screen.pos+st.pos)\n vy:if pointer.down&grounded -20 else st.vel[1] end\n vx:if -20>relpos[0] -2 elseif relpos[0]>20 2 else 0 end\n \n vy    :vy+1                  # gravity\n st.vel:.9*vx,vy              # friction\n st.pos:st.pos+st.vel         # inertia\n st.pos:0|screen.size&st.pos  # solid walls/floor\n \n screen.clear[]\n screen.rect[st.pos-0,10 10,20 \"center\"] \n \n state.text:\"%j\" format st\nend","widgets":{"screen":{"type":"canvas","size":[195,186],"pos":[159,73],"animated":1,"volatile":1,"scale":1},"state":{"type":"field","size":[100,121],"pos":[379,101],"value":"{\"vel\":[0,8.891043],\"pos\":[3.6,186]}"}}},"d":{}}

Thanks, we are excited but more than a bit daunted. To show you what level I am at is my next question: Where do you put that code  in a script box?

Developer (1 edit)

The block of code above starting with "%%CRD0" is what a card looks like in the system clipboard. If you select and copy the entire thing from your web browser, in Decker you should be able to choose "Edit -> Paste Card" from the menu and then have the entire example to play with interactively and modify.

It might be best to tackle some simpler projects that involve scripting before diving in the deep end. There are lots of useful examples and discussions here in the community forum. In particular, it might be worth trying the examples in these tutorials to gain some familiarity with adding interactivity to decks:

Make your own Chicken Generator: https://itch.io/t/3593043/make-your-own-chicken-generator

Building a Font Importer: https://itch.io/t/3177237/building-a-font-importer

Scripting One-Liners: https://itch.io/t/2929513/scripting-one-liner

(+1)

Boy did I have fun. The project, if it can be called that, has gone in another direction. I am conceptualizing doing an RPG suite on Decker. Character sheets, dice roller, maybe even a dungeon generator. Eventually I would love to do a primitive roguelike. But now focusing on the notebook.