Get Me Out (comrade Gamedev) Mac OS

Posted on  by

24 hours of game dev in Rust

For many of us, the reasons we get into gamedev is that we really want to play a certain game, which doesn't exist, so we toil away at it for months and years to create it. Five years ago I really wanted to play a 3D, topdown, twin-stick shooting game that has some roleplaying, survival, and stealth aspect. Unreal engine and unity are both well supported on Mac. Using a Mac for game dev is in no way a disadvantage for gamedev IMO. Monogame, libgdx, and pygame are also well supported and crossplatform. If you can swing the $99 and have an iOS device then I'd also highly recommend taking a look at spritekit or spritebuilder and building a mobile game. Two options, control click or right click on it’s icon in the dock and select open at startup which will have a check mark. That will remove the check mark and stop it from opening or launching on startup.

A self imposed game jam trip report

Me

  • Michael Shaw
  • Years of developing games in Scala
  • 24 hours of Rust experience

Why

I started off building big, learning slowly

Most of my ideas are bad
'Require Iteration'

Learning out they're bad in 24 hours
is much cheaper than 3 months

Scala

Might be the best game jam language in existence

  • Performance is easily good enough
  • Type safety + terse (fast dev)
  • Fast incremental compiler
  • Functional programming with escape hatches

Painful long term

  • Distribution & garbage collection woes
  • High cost abstractions hard to distuinguish
    from low cost ones
  • Clean code murders the GC
  • GC friendly code is nasty

Rust

  • Expressive (but not terse), fast, no GC
  • Tree based ownership over structural sharing is fine with games
  • Zero cost abstractions (for the machine)

Can you make it 'Game Jam' friendly though?

Can we create a layer of machine inefficient,
developer productivity based shortcuts?

Something you start with,
and phase out when you need speed ...

What

Glium & Glutin overview

Game jam style engine design

A smidge of game design

Building a tiny game

Cheating

I read https://doc.rust-lang.org/book/ beforehand

I only counted development.
There were a few hours planning with what to build.

24:00

Thievery and triangles

Glium

https://github.com/tomaka/glium

Safe OpenGL without the state machine.

  • Forget about glEnable/glDisable/glBind/glUnbind ...
  • Don't look at the issue count on github, everything is fine

Target

What we're drawing on (window, or off screen)

vertex_buffer

Vertices that we want to draw (usually triangles)

program

A pair of GLSL programs/'shaders'
Vertices + Uniforms in -> Coloured pixels out

uniforms

Shader program state
(textures, colors, camera transforms)

Pretend the (!) isn't there and that it's just a struct.

That ! is saving you from 24 years of OpenGL's legacy

When you see a ! you're exchanging a few hours of runtime trial and error for a runtime error on program start

Uniforms

Shaders

Becomes

Mac OS X Notes

Demand a core profile

Make your shaders 3.3+

Glium examples are really easy to run (steal them)

Print input events to get familiar

Glutin

https://github.com/tomaka/glutin

Cross platform:

  • Window Creation
  • Input Events
  • OpenGL Context Creation

23:00

An ounce of organisation

Paying the piper

An hour spent learning Rust's module system

You know what I said about stealing everything ...

Throw it out and add it back line by line

lib.rs

Forget your managed namespaces

module directives form a tree

Named pointers, not namespaces

Halfway between namespaces & include directives

22:00

An ounce of organisation

Piper needs a brand new car

An hour spent battling glium Types

All the examples are one function, so there's no examples of:

I'm pretty sure I shouldn't be passing around a GlutinFacade.

An hour later I find ...

Because I'm new at Rust :-/

21:00

Game jam style rendering

Quick & Dirty

2D sprites positioned in 3D (more than Z order)

Quads only, in one vertex format

At most a few batches per frame

Dev performance, not machine performance

'Flash' guys in the middle with per vertex colors

One fat vertex format

color allows us to flash guys white if they get hit
or red if they're hurt

normal allows us to add lighting if we have time

(Poorly) recoloured sprites for different teams

Texture Arrays are your friend

Great for sprites

Run out of space?

Add another layer

Different sides/factions?

Add layers with recoloured versions

image

https://github.com/PistonDevelopers/image

The last image library you'll need

Getting Quads back

OpenGL doesn't have quads

We can just duplicate bottom-left and top-right vertices

Efficient* Quads

*Developer efficient, embrace #Derive(Copy)

20:00

Generating geometry: Walls and Floors

'Base Anchored Wall'

'Smart' quad tesselator understands desired pixel scale and texture sizes to give consistent pixel density

Get

Rendering becomes

18:00

Cameras and Tiles

cgmath

https://github.com/brendanzab/cgmath

All the vecs, mats, dots, crosses and inverts you need for a game

Pixel Perfect Camera

Blending & Depth

16:00

Everything's wrong and I hate the world

Assumed my camera creation was wrong, and spent an hour debugging it

Example shader had matrix multiplication reversed

15:00

Interaction

Input Handling

We need to remember a few things between frames

Get Me Out (comrade Gamedev) Mac Os Download

Gamedev)

Mouse Picking

From windowed mouse coordinates to world objects

In our main loop

12:00

Hey, you said there'd be games you lying bastard ...

Game in 12 hours anyone?

Set your expectations low

No, lower than that, like real low

Think

Tile laying
&
Mountain climbing

Grom, The Mountain God

Good? Evil? You're the big stone head

Help everyone up?

That's just lemmings

Make sure nobody gets up?

That's just weird tower defense

Get the chosen one to the mountain top

> 1 You Lose ... < 1 You Lose

Who's the chosen one?

Clearly the guy that made it

Climbing is dangerous

11:45

Let's reverse things

9:00

First Steps

#[derive(Clone,Copy,Debug,Eq,PartialEq)]

Simple & Inefficient
Why borrow when you can copy? (don't answer that)

Get Me Out (comrade Gamedev) Mac Os Catalina

Disclaimer

This is not idiomatic Rust, these are the fever dreams of a Scala developer who can't even remember what life is like without a garbage collector

Game State

Tiles

World Gen

Rendering it

7:00

Placing tiles

5:00

Ears for sound

  • Simple cross-platform sound
  • Needs OpenAL & libsndfile at runtime
  • Works cross platform (unlike some others)

4:00

Now with climbers

Climbers

Rendering climbers

2:00

ClimberS, it's ugly code time

Movement Rules

Get Me Out (comrade Gamedev) Mac Os 11

  1. If you're at the stone head, climb in
  2. Go somewhere new that's not down
  3. Go somewhere new (that's down)
  4. Wait (and reset where you've been)

Travellable Locations

Everything would be a stack allocated
lazy iterator if I was better at this

00:00

Everybody loves chiptunes

https://soundcloud.com/eric-skiff/come-and-find-me

Eric Skiff

Springs for smoothness

Attach them to everything

Parallax clouds

Realistic head bob

'Dynamic' crowd sounds

3D climbing depth

Thanks for listening

Engine source is up at
https://github.com/MichaelShaw/rust-game-24h

Game is up at
https://github.com/MichaelShaw/grom

So, it was the end of the line for my 27″ 2011 iMac. After 7 years of service, the new OS (MacOS 10.14 “Mojave”) wasn’t going to be able to be installed on the old faithful. There’s some tech reasons for that – Apple moved to minimum standard for graphics cards for their system (they have to support Metal). While there’s external GPU’s for my iMac, I haven’t seen one that supports Mojave. And, even if it did, I probably can’t afford it.

And I certainly can’t afford a new Mac at the moment.

The is a bit of an issue, since I’ve got to be able to compile a project for release very soon. Well… shit.

Fortunately, there’s always someone somewhere that wants to get just a little more life out of their machine – in this case, the Mojave Patcher will do some trickery to load MacOS on a machine that’s not supposed to have it. Nice. Though, reading the notes, it mentions machines with a Radeon 5xxx or 6xxx series GPU had weird colors. Well, how bad could it be.

The answer is very. But, there’s a simple fix (for me, at least). Typically, I run dual screen. When starting the process, I turned off the second screen and went about installing, getting everything working, and back to developing software. It would be unusable with the “weird colors” if I wanted to do any graphics work.

I turned the second screen back on, which is attached via Thunderbolt to HDMI. Boom – suddenly all of my colors were correct again!

That didn’t solve the other problems, though – hardware acceleration is disabled, which means my fairly snappy iMac runs like a dog. For doing something like writing this blog, it’s fine (I’m using Chrome, though results appear the same in Safari.) I would have said YouTube would be worthless, but actually it seems to run YouTube videos just fine. Same goes for NetFlix, though there’s some issues with the animations for launching a show.

I’m dreading seeing what performance is like running the Android or iOS emulators (if they launch at all.) . I’ll find out what the damage is there tomorrow.

So is Mojave usable on my old machine? Yes. Is the machine still usable? Yeeeaaahhhh… for the most part. I think it’s gonna take me a bit to get used to the laggy interface. Since I have to compile stuff and sign it for the App Stores, I HAVE to run Mojave, otherwise I wouldn’t have bothered with the upgrade. Should you bother with it? Up to you if you’re on an old, unsupported Mac. (Obviously if you’re on a supported Mac, by all means upgrade)

Run into the color issue? Try plugging in a second monitor and see if that does the trick. Honestly, I have no idea why it worked, but it does. 🙂

Two updates to this (and probably some more to come later):

First, scrolling in Safari was laggy and choppy. Dragging windows around was choppy. Quick fix – lower the resolution from the maximum (2560 x 1440) to one step top (1920 x 1080) pretty much eliminated it. Not butter smooth, but a huge improvement on all of them. It’s much more usable.

Now for the “wow, that gets weird” part: the “weird colors” issue reappeared on my main monitor, but the secondary display has the right colors. Reverting back to the previous resolution doesn’t fix it. Definitely a WTF item. 🙂