Log In  

BBS > Community Superblog
All | Following | GIFs | Off-site

Thought I would share some code I've been using for my pico-8 game. It's a simple class library that also includes inheritance.
139 Tokens
617 Characters without comments

How to Use:
Create a new instance with function "new".
The first variable is always the table that holds all the variables, 2nd and onwards are used for the function "__init('table','...')"
Example:

player:new({variablea=1,variableb=2},initarg1,initarg2)

Variables are copied over just fine, however for tables if you don't want each instance to share the exact same table with each other then I would recommend defining them in the function "__init('table','...')".
Example:

--do this
function newclass:__init(varc,vard)
  self.vartable={varc,vard}
  self.varemptytable={}
end

--if you don't do that then
instance1.varemptytable==instance2.varemptytable

When creating a class, you can inherit from other classes upon it's creation by simply including classes after the first argument.
Example:

newclass=cwi:new({vara=3,varb=4},classtoinheritfroma,classtoinheritfromb)

You can also inherit from other classes by running function "inherit('...')".

Classes have an "init" function that is run every time a new instance is created.
Classes that have been inherited from will NOT run their function "
init('...')" upon creation of a new instance.

Function "oftype('class')" allows you to check each if one class is of the type of another.
Classes that have been inherited will also return true for function "oftype('class')".

Finally I present the code:

--Classes With Inheritance!
cwi={}
cwi.__index=cwi

function cwi:__init(...)
  self.__types={}
  if #{...}>0 then self:inherit(...) end
  self.__init=function() end             --create an empty function so all classes function "__init" doesn't inherit
end

function cwi:new(r,...)
  r=r or {}
  r.__index=r
  setmetatable(r,self)
  if r.__init then r:__init(...) end
  return r
end

function cwi:inherit(...)
  local function c(a,b)
    for k,l in pairs(b) do
      if not a

[ [size=16][color=#ffaabb] [ Continue Reading.. ] [/color][/size] ](/bbs/?pid=70752#p)
2
0 comments


I rushed home to post this on time before passing to the next day and therefore skipping my daily post. Yesterday I was reading through this awesome Pico-8 guide:https://mboffin.itch.io/gamedev-with-pico-8-issue1

Managed to draw my first sprite and coding my first engine which was one very simple and all I could do was to move the sprite with the arrow keys around the screen. I learned about the Pico-8 console and how to switch between the terminal and the editing mode and getting familiar with the different tools it provides.

Very straight forward learning experience so far, Lua feels very familiar and very easy to comprehend if you're familiar with any other programming language.

Time to learn more about Pico-8, later guys.

0 comments


Cart #starswing-0 | 2019-12-09 | Code ▽ | Embed ▽ | No License
17

Do you see what I see?

Click your mouse to swing the Christmas Star into its rightful place in the sky.

Day 9 for the PICO-8 Advent Calendar, 2019

17
2 comments


Cart #cos_sin_visualisation-2 | 2019-12-09 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
3

Credits to @MBoffin for inspiring me to code this too

Controls:

  • Press X to toggle Autopilot / Manual Control
  • Left arrow key -> turn cclockwise
  • Right arrow key -> turn clockwise
3
5 comments


Cart #cooling_particles-0 | 2019-12-09 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
3

Inspired by @dw817

Controls:

-Arrow Keys to move

// comment cls() call in draw method for those effects:

3
7 comments


Cart #zasutuwuzo-0 | 2019-12-09 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1

1
2 comments


Cart #zachstronaut_simplegalaxy-1 | 2019-12-09 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1

A galaxy generated from a parameterized spiral equation. Simple fake 3D camera.

1
1 comment


Cart #xmascard-0 | 2022-12-08 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
7

(v01 12-08-22)
TO LOAD THIS PICO-8 CART, in immediate mode, type: load #xmascard

VVhat's new ?

Gruber, one of the the resident Pico-8 musicians came through, was very kind to me, wrote to me on his page, and offered what I could use for my Christmas project here. How wonderful !

-- 12-08-22
-- + used extended memory to
assist in the opening of
the card.

-- 12-08-22
-- + improved speed of
-- scrolling text.

-- 12-08-19
-- + added changing wind
-- direction.

-- 12-09-19
-- + added 3d card opening
-- graphic. tricky stuff.

The music that I wrote I am keeping (the post after this one). It's a curious method to be sure where all notes are the same length and some are repeated in different octaves to maintain the flow of the song.

[ Continue Reading.. ]

7
3 comments


Cart #moziguname-0 | 2019-12-08 | Code ▽ | Embed ▽ | No License

this is aggressive blaster snata guy dude (blood involved)

3 comments


Cart #flappy-0 | 2019-12-08 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
4

here is a cart with some extra explaination in the code for my upcomming tutorial video

4
1 comment


Cart #pico_dictator101-0 | 2019-12-08 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
6

Ok, here's the bug fixed version 1.01 of Pico Dictator.

This is a pico-8 demake of one of my childhood memories, the turn based strategy game "DICTATOR" for the Sinclair ZX Spectrum.

I didn't recreate it 100% but instead tried to recreate the look and feel of the game (I added some more graphics etc). The internal engine for the game rules though should be nearly identical.

In DICTATOR you are the ruler of the African banana republic Ritimba and you need keep the different factions of the country - the army, the peasants and the landowners - happy while working tightly together with your secret police. Other parties you need to manage are the guerillas, the neighbor Leftoto, the Russians and the Americans.

[ Continue Reading.. ]

6
0 comments


... The entire Metroid map, converted to the PICO-8 palette and 8x8px sprites @.@

https://www.uomni.com/img/metroid.pico.edited.png

2
7 comments


Hello all!

Finally purchase Pico-8 and quite excited to get started, I have limited coding experience to be honest but I've dabbled in many languages (Mainly Python, BASIC and a little C#) and read several books on computer architecture so hoping this might be a 'not too big' jump into the video gaming world.

I have read a variety of posts about Pico-8 now and am excited to get started however a few questions have cropped up if anyone thinks they could help!

1) I love the idea of limitations with the console however I like the idea of being able to start small and watch it grow, how tight are the limitations in practise and are there any work arounds if I get going?

2) The game I want to design at some point down the line is basically a small version of The Sims...my thoughts are it will be set in one house or maybe a very small town where you go to work, buy furniture and gradually upgrade a few skils. Ofcourse naturally I would scale down on each aspect to include what hopefully sums up the franchise. I'm thinking game length and interest would be held by keeping the map/world small but adding features to a small base. The question here really is do you think this kind of project would be doable with the tools/limitations of Pico-8.

[ Continue Reading.. ]

2
4 comments


This is my first day here, I got Pico-8 from a humble bundle and been thinking about getting into it for a while, I set up everything to start with it a couple of days ago and TODAY I will start reading some tutorials because I know nothing about how to code in Lua but I'm always up for a challenge.

So let's see how far I can reach this day.

0 comments


Cart #dancesantarevolution-0 | 2019-12-07 | Code ▽ | Embed ▽ | No License
12

Proud part of the PICO-8 Advent Calendar 2019.

About

This year Santa Claus is in an incredible mood for dancing... enjoy a small Christmas Doodle!

Credits

Cart by Matthias Falk
Music by gruber
Snow effect adapted from a code example by trasevol_dog, inspired by CELESTE (Matt & Noel)
Santa animation by northpole.com
On https://pocketfruit.itch.io you can find my other games and follow me for updates.

Audio not playing? For Google Chrome and Safari, please refer to this

[ Continue Reading.. ]

12
10 comments


Cart #lazy_farm-0 | 2019-12-07 | Code ▽ | Embed ▽ | No License
5

Hi! I developed a puzzle game based on the classic Sokoban.

The itch.io page for the game contains more information, various downloads and the game manual.

5
1 comment


Certainly not the first block-stacking game, but this might be the first one on PICO-8 with global high scores*!

Play the game here*:

https://jaredkrinke.itch.io/fbgp8

How to play

The goal of the game is to score points by clearing lines. You clear lines by rotating and dropping pieces into complete lines (no gaps). The more lines you clear at once, the more points you score.

Pro tip: pieces fall faster on higher levels, but you get more points, so if you can handle it, try starting on level 9.

Game modes

  • Endless (exactly what it sounds like)
  • Countdown (game ends after 25 lines)
  • Cleanup (same as countdown, but the play area starts filled with garbage)

High scores

High scores are tracked both locally and globally*.

See if you can make it into the top 10! (Update 12/13: getting on the list is no longer easy :)

Code

[ Continue Reading.. ]

6
5 comments


Cart #f8_faster_than_light-0 | 2019-12-13 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
4

The goal is to make a pico8 version of Faster Than Light.

I am planning to remove all the crew management + route planning and focus on dogfight.
A big part of what makes FTL great is the balance so I am not sure yet if the game will make sense.

Going to work on this more in the coming days.
Send some love if you would like to play it.

Also I suck at making music so if you like the project and want to do the tracker part. Get in touch.

4
6 comments


Cart #creedfighter-1 | 2019-11-24 | Code ▽ | Embed ▽ | No License
5

For Saint Nicholas Day, I made a game inspired by my favorite St Nick legend: that one time he punched a heretic.

It's a 2-player fighting game, controllers recommended. Enjoy!

5
1 comment


Cart #polarpanic-0 | 2019-11-25 | Code ▽ | Embed ▽ | No License
111

Here's my entry for the Pico-8 advent calendar 2019:

POLAR PANIC

  • Stay alive in the arctic while climate change destroys your habitat!
  • Eat fish to keep your hunger down or you will starve!
  • Stay away from trash and don't fall into the water.

Controls

⬆️ ⬇️ ⬅️ ➡️ - jump between floes

That's all there is to it really!
Every now and then disaster strikes which will make it harder to stay alive.
Do your best and good luck!

Credits

Design/Art/Code: Johan Peitz (@johanpeitz)
Music/Sound: Chris Donnelly (@gruber_music)

111
24 comments




Top    Load More Posts ->