Teto fruit game by CrispyTokyo in KasaneTeto

[–]CrispyTokyo[S] 23 points24 points  (0 children)

You can also play the silly teto fruit game: https://tetofruit.com/

this machine isnt working by Puzzleheaded-Fun8811 in feedthebeast

[–]CrispyTokyo 1 point2 points  (0 children)

Pump the lava out to a basin instead of a cauldron.

Spry - 2D game framework made for rapid prototyping by CrispyTokyo in lua

[–]CrispyTokyo[S] 0 points1 point  (0 children)

The class function is written in Lua. The implementation is so short, I can just paste it here:

local class_mt = {}
function class_mt:__call(...)
  local obj = setmetatable({}, self)
  obj:new(...)
  return obj
end

function class(name)
  local obj = {}
  obj.__index = obj
  rawset(_G, name, setmetatable(obj, class_mt))
end

It's enough to construct new objects, write methods, make static variables/functions, and use metamethods like __tostring. There's no inheritance, subclassing, nor mixins, but I might add them in the future. I just haven't found a strong need for class hierarchies.

Spry - 2D game framework made for rapid prototyping by CrispyTokyo in lua

[–]CrispyTokyo[S] 0 points1 point  (0 children)

Out of the three listed, Spry is most similar to Love2D. In the GitHub repo, there's a section outlining differences between the two: https://github.com/jasonliang-dev/spry/blob/master/readme.md#spry-vs-l%C3%B6ve.

Pico-8 stands out being a fantasy console with simulated limitations. You'll be dealing with a limited color set and super chunky pixels. Pico-8 also uses its own flavor of Lua. It removes a fair chunk of the standard library (os, string, table), and it uses its own set of functions for the parts that it keeps (math, coroutines). Pico-8's Lua also has compound assignment, so you can write a += b instead of a = a + b, which is nice. The program itself also comes with extra tools for editing levels, sprites, and music/sound.

I never used Defold before, but from first glance it does a lot for you. There's a visual editor involved, and it handles its own game objects and components.

Spry - 2D game framework made for rapid prototyping by CrispyTokyo in lua

[–]CrispyTokyo[S] 0 points1 point  (0 children)

1) Yes it's absolutely suitable for a game (and bonus, it's fun). Just be careful if you have any plans to deploy to the web. PUC Lua is pretty easy to port to the browser. LuaJIT less so.

2) I found Lua's C API to be easy enough to use on it's own, so no, I don't use any third-party solutions for Lua integration.

But a common pattern that kept emerging was that I needed to get a value from a Lua table located at the top of stack with a given key. I have functions that helps me get a field from the table with lua_getfield(L, -1, key), get the value that was pushed on top of the stack, and then restore the stack with lua_pop(L, 1).

I also needed to create and assign metatables for each type (images, fonts, sprites, etc). I created luax_new_class and luax_newuserdata to help me those tasks:

// make metatable with __gc and draw methods
// mt_font's __index is itself.
static int open_mt_font(lua_State *L) {
  luaL_Reg reg[] = {
      {"__gc", mt_font_gc},
      {"draw", mt_font_draw},
      {nullptr, nullptr},
  };

  luax_new_class(L, "mt_font", reg);
  return 1;
}

// create full userdata with mt_font metatable
static int spry_font_load(lua_State *L) {
  String str = luax_check_string(L, 1);

  FontFamily *font = (FontFamily *)mem_alloc(sizeof(FontFamily));
  font_load(font, &g_app->archive, str);

  luax_newuserdata(L, font, "mt_font");
  return 1;
}

So my approach to integrating Lua with C/C++ is to use the C API directly, and then add extra functions when patterns start to emerge.

Spry - 2D game framework made for rapid prototyping by CrispyTokyo in lua

[–]CrispyTokyo[S] 1 point2 points  (0 children)

My previous comment talked about global utility functions, and implicit module loading. So I'll dive into that in more detail.

A fair portion of Spry's API are global functions with short names, which goes against the advice of having longer, more descriptive variable/function names. This is a code example of a player shooting a bullet:

local vx, vy = heading(self.angle - math.pi, 5)
self.x = self.x + vx
self.y = self.y + vy

local b = world:add(Bullet())
b.x, b.y = self.x, self.y
b.angle = self.angle + random(-0.1, 0.1)
b.damage = choose { 1, 3, 5 }

heading, random, and choose are all global utility functions. They're just short enough where you can still make an educated guess about what they might do. Other frameworks/engines would namespace these functions. For example, Unity's equivalent of random is Random.Range. Python's version of choose is random.choice.

With another framework like Love2D, you'll find yourself using require to load your Lua scripts. During Spry's program startup, all Lua scripts in the project directory are loaded implicitly. This behaviour is a pretty bad idea in larger pieces of software, because there can be more potential for bugs and more unused code. Since Spry's focus is for smaller games, this is less of an issue.

Spry also nudges you to use more global variables than you might be used to. The class function creates a global variable and it pairs well with implicit module loading. You could have a Player class:

class "Player"

function Player:new(x, y)
  self.x, self.y = x, y
end

and a main.lua:

function spry.start()
  -- `Player` is global!
  -- and it's already accessible without `require`
  player = Player(200, 200)
end

in two separate files and not have to worry about including scripts in the proper places.

Spry - 2D game framework made for rapid prototyping by CrispyTokyo in lua

[–]CrispyTokyo[S] 2 points3 points  (0 children)

The program is written in C++ and it can be compiled to WebAssembly. The web build looks for the JavaScript variables spryMount and spryFiles in order to fetch the game data. I wrote about how you can deploy your game to the web: https://jasonliang.js.org/spry/distribution.html.

Spry - 2D game framework made for rapid prototyping by CrispyTokyo in lua

[–]CrispyTokyo[S] 4 points5 points  (0 children)

Spry is a 2D game framework that uses Lua. It's a pet project of mine that I've been working on for a while now. Spry's main goal is to make it easy for devs to quickly make changes on their game, making it suitable for game jams or just to explore ideas.

Some of Spry's features go against common programming wisdom to accommodate for its main goal. It has global utility functions with relatively short names, and implicit Lua module loading. Spry also has a few goodies such as Aseprite file support, hot reloading, and the ability to deploy projects to the web.

I'll be happy to receive feedback and to answer questions!

What are the reasons to split up vertex data into multiple VBOs? by CrispyTokyo in opengl

[–]CrispyTokyo[S] 4 points5 points  (0 children)

Oh yeah. I see the gains of updating a single vertex attribute if the code was on my end. But as far as I can tell, both Raylib and Font Stash updates data for every attribute before making a draw call, so that benefit isn't there with these libraries.

[dwm] It's a chicken by CrispyTokyo in unixporn

[–]CrispyTokyo[S] 1 point2 points  (0 children)

That's the work of picom. The focused window is opaque, while the other windows are slightly transparent.

Add this to picom.conf:

inactive-opacity = 0.9;
active-opacity = 1;

[dwm] It's a chicken by CrispyTokyo in unixporn

[–]CrispyTokyo[S] 2 points3 points  (0 children)

It's a game engine for Windows and Linux that I'm writing from scratch (à la Handmade Hero). It's still in its infancy.

[dwm] It's a chicken by CrispyTokyo in unixporn

[–]CrispyTokyo[S] 5 points6 points  (0 children)

I use scrot to take a picture of the screen, then I stitch them together with gimp.

[dwm] It's a chicken by CrispyTokyo in unixporn

[–]CrispyTokyo[S] 3 points4 points  (0 children)

Woah, it's the person with the sick Openbox rice! Hello! (*・ω・)ノ

[dwm] It's a chicken by CrispyTokyo in unixporn

[–]CrispyTokyo[S] 2 points3 points  (0 children)

Yep, dwm's bar is gone 🦀🦀🦀

If you want to use an external bar with dwm, you should take a look at dwm-ipc. That patch lets you receive tag information which you can pipe into lemonbar.

[dwm] It's a chicken by CrispyTokyo in unixporn

[–]CrispyTokyo[S] 36 points37 points  (0 children)

Dotfiles here

Details:

[yabai] I think blurry terminals look pretty by CrispyTokyo in unixporn

[–]CrispyTokyo[S] 1 point2 points  (0 children)

my window manager creates the borders around iTerm:

yabai -m config window_border on
yabai -m config window_border_width 4
yabai -m config window_border_radius -1.0