Log In  
Follow
Stompy
SHOW MORE

Is it possible to export Voxatron games to html/js like pico-8 can? I would like to host games on itch or my own website if possible. I saw that you can embed the player from the bbs, but that's less ideal than self hosting.

P#79610 2020-07-19 16:02 ( Edited 2020-07-19 19:56)

SHOW MORE

Hey everyone. I recently released Goober's in the Mix. It was my first bigger pico game that actually required me to optimize for tokens. I wrote a lot of pseudo object oriented code with classes and inheritance. I found myself with a lot of code that looked like this:

local thing = class{
   update = function(self)
      -- cache a bunch of properties
      local x, y, dx, dy, health, frozen, invuln = self.x, self.y, self.dx, self.dy, self.health, self.frozen
      ... game logic in here
      -- resync all those properties on the instance
      self.x, self.y, self.dx, self.dy, self.health, self.frozen, self.invuln = x, y, dx, dy, health, frozen
   end
}

All that caching and syncing saves tokens instead of referencing self in the logic, but we can save more.

Lua has a feature called environments that lets you alter how global variables are looked up. So I altered my initial class declaration to look something like:

_G = _ENV -- just a new name to distinguish this as the original global scope
_G.__index = _G -- if _G is used as a metatable, it will look itself for unfound properties

local class do
   local mt = setmetatable({
      update = noop, -- defaults
      draw = noop, -- defaults
      init = noop, -- defaults
      __call = function(self, o) -- takes an table of nondefault values
         o = o or {} -- empty table if none given
         setmetatable(o, self) -- each instance sets itself as the new prototype
         self.__index = self -- looks in itself for unfound properties
         self.__call = getmetatable(self).__call -- sugar to allow calling class like a function
         o:init(self) -- call an init/constructor function if given

         return o -- return the new instance
      end
   }, _G) -- the class mt is the global scope !IMPORTANT
   -- if you don't keep this reference to global scope you're going to run into trouble later [1]
   mt.__index = mt -- this class mt indexes itself if child doesn't have a property
   class = setmetatable({}, mt) -- set the classes metatable
end

Most of this is pretty standard for classes in Lua. But the magic comes in with that global reference. This allows us to use environments without breakings everything.

dog = class{
   x = 10,
   update = function(self)
      local _ENV = self -- set self as the new environment
      if (x < 127) x += 1 -- we can now reference self.x as just x.
   end
}

Things to note:
_ENV is where globals are looked up. Like how globals are found on the Window object in client-side javascript. Normally when you reference a global `z` it's the same as referencing `_G.z` or `_ENV.z` in Lua. So when you change the local value of `_ENV` within that scope, it will reference what ever you set as the value instead.

This means that things previously available in the global scope may not be there. Like the pico api functions. `print`, `rectfill`, `time` etc wouldn't be available. This is why we added that reference to `_G` in our lookup chain.

This also means you can have weird variable shadowing issues when you think you're altering a global but really creating a new property on your class instance or vice versa. You can use that `_G` reference or `self` reference directly if you know you're shadowing an existing variable in a parent scope.

When I first refactored to add this technique i saved something like 1.5k+ tokens removing all those caching variable and the syncing back to the instance values.

Hope this saves you all a bunch of tokens and continues to move the meta forward! Happy to answer any questions or make revisions as needed.

P#79549 2020-07-18 11:12

SHOW MORE

Cart #goobers_in_the_mix-10 | 2020-08-30 | Code ▽ | Embed ▽ | No License
8

edit: fixed the sluggish jumps
edit: tightened up camera, added some tips about switching items, shrunk spike hitboxes, added some helpful tiles in the firepit
edit: widened the rat/bat safety window, added a chest near the star door which gives you an extra heart and serves as a 1 time savepoint
edit: healing salve only replenishes a heart, cap is still 4 hearts
edit: fix collisions at trigger points
edit: add skull to door guarded by boss & add visual feedback when boss is hit
edit: changed the healing salve to a full checkpoint, rat doesn't spawn under the double spikes until after you get the first potion, added a in-game tip about using potions, added another checkpoint in the firepit, took the corner off the annoying ledge over the firepit spike jump, changed boss dialog to make it more clear about what he does or doesn't have in his possession.

First larger game (sitting at 8180 tokens atm). Goober's in the Mix is a metroidvania in a dungeon setting. You play Goober the goblin and need to investigate a disturbance in the dungeon. Constructive criticism welcome as well as token saving tips.

Music by Cody Loyd.

Post your win screens.

P#79334 2020-07-14 21:24 ( Edited 2020-08-30 11:55)

SHOW MORE

Cart #office_escape-0 | 2019-12-15 | Code ▽ | Embed ▽ | No License
5

Made for 2-Button Jam 2019

Source is on github.

It's released MIT licensed.

Music was done by Cody Loyd.

Update 1.1: Now shows score for all gameovers

P#71044 2019-12-15 19:25 ( Edited 2019-12-17 06:00)

SHOW MORE

Just going to start a thread here for bugs in the text as they're found so we can keep them all in one place.

P#65596 2019-07-05 12:13 ( Edited 2019-07-09 19:00)

SHOW MORE

Hey guys, don't know how many people follow Zep on Twitter, but, thought I'd share some news:

"100% Lua scripted" - from 2:50 am - 17 May 2018

P#53120 2018-05-30 12:08 ( Edited 2018-06-26 20:48)

SHOW MORE

Cart #44739 | 2017-09-29 | Code ▽ | Embed ▽ | No License
7

Rhythm Game made in about 50 hours for Music Game Jam. Team of codyloyd and myself. First jam for both of us.

Hit the buttons to the beat while avoiding the asteroids.

P#44740 2017-09-28 22:32 ( Edited 2017-09-29 02:32)

SHOW MORE

Hey guys! This is my first game I felt was good enough to post here. It's not perfect but it's pretty fun. It's a demake of a LOVE game I made.

It's MIT licensed so if you like something in it, feel free to riff or rip.

Let me know what you think or where I can improve.

Cart #44050 | 2017-09-10 | Code ▽ | Embed ▽ | No License
2


Good luck!

P#44051 2017-09-10 13:13 ( Edited 2017-09-16 13:44)

SHOW MORE

I've been seeing a lot of version spam in Splore while browsing, and I'd like to avoid doing that myself if I can avoid it. But I'm not entirely sure how Splore works. Is there some sort of wiki info about it? Or a guide some where? Are there best practices for stuff like versioning/cart data/naming?

P#33896 2016-12-21 23:48 ( Edited 2016-12-23 01:22)

Follow Lexaloffle:          
Generated 2024-03-19 03:52:20 | 0.078s | Q:24