-
Notifications
You must be signed in to change notification settings - Fork 3
Your first Project
Hello Goodbye World, because Hello is overrated, you'll be creating a simple Goodbye World
.
Though you'll need a font first, sorry, we (well mostly IceDragon) forgot to package a font with Moon.
From this point on, its assumed you'll be using moon-player
to run and test your projects.
First up you'll need a font, go swipe one off the interwebs, or just grab one from your local font directory or something.
You create a Font object by doing the following:
# signature
font = Moon::Font.new(filename, size)
# usage
font = Moon::Font.new('resources/fonts/Arial.ttf', 18)
Customarily, you'll put all assets/resources in resources/
in a proper directory, but thats just us, feel free to go crazy with uber-tastic-place-to-store-my-assets/things-that-go-on-the-screen/Arial.ttf
, I ain't stopping you.
Now for a gotcha, if you looked in the bootstrap, you may have noticed that you don't get any methods setup or termination, this may be considered in the future but for now, just lazy initialize your stuff in step, or better yet, write your own bootstrap and share it with us.
So to get your font on the screen.
in scripts/load.rb
def step(engine, delta)
@font ||= Font.new('resources/fonts/Arial.ttf', 18)
@font.render(24, 24, 0, 'Goodbye World')
end
Assuming all went well in the world and your house didn't explode because of a random segfault, you should see 'Goodbye World' in the top left corner of your window, in white.
You can have color, by passing a 5th parameter to Font.
in scripts/load.rb
def step(engine, delta)
@font ||= Font.new('resources/fonts/Arial.ttf', 18)
@font.render(24, 24, 0, 'Goodbye World', Moon::Vector4.new(0, 1, 0, 1))
end
Now you must be screaming, "WHERE IS Moon::Color
?" the answer, there is none, there will never be one, get used to it; Moon::Vector4
is now your Moon::Color
.
Congrats you now have a Goodbye World
program in Moon.