ramp-collision.mp4
class Game
attr :args
def defaults
args.state.terrain ||= [
{ x: 0, y: 0, w: 128, h: 128, left_perc: 0, right_perc: 0.5 },
{ x: 128, y: 64, w: 128, h: 128, left_perc: 0, right_perc: 1.0 },
class Game
attr :args
def defaults
args.state.terrain ||= [
{ x: 0, y: 0, w: 128, h: 128, left_perc: 0, right_perc: 0.5 },
{ x: 128, y: 64, w: 128, h: 128, left_perc: 0, right_perc: 1.0 },
def tick_intro args | |
[ | |
Layout.rect(row: 0, col: 12) | |
.merge(text: "DragonRuby Game Toolkit: Lessons Learned", | |
alignment_enum: 1, | |
vertical_alignment_enum: 1, | |
size_enum: 10, **white), | |
Layout.rect(row: 1, col: 12) | |
.merge(text: "Amir Rajan", **centered_white_label), | |
Layout.rect(row: 1.6, col: 12) |
class Game | |
attr :args | |
def defaults | |
args.state.terrain ||= [ | |
{ x: 0, y: 0, w: 128, h: 128, left_perc: 0, right_perc: 0.5 }, | |
{ x: 128, y: 64, w: 128, h: 128, left_perc: 0, right_perc: 1.0 }, | |
{ x: 256, y: 64, w: 128, h: 128, left_perc: 0.5, right_perc: 0 }, | |
{ x: 384, y: 64, w: 128, h: 128, left_perc: 0, right_perc: 0 }, | |
] |
class Game | |
attr_gtk | |
def tick | |
defaults | |
input | |
calc | |
render | |
end |
class Game | |
attr_gtk | |
def initialize | |
end | |
def defaults | |
state.objects ||= [] | |
end |
Things to consider when building a cross-platform game:
class Player | |
def initialize | |
@action_lookup = { | |
idle: { | |
frame_count: 7, | |
dir: "sprites/player/idle", | |
repeat: true | |
}, | |
attack: { | |
frame_count: 6, |
def tick args | |
# initialize state | |
args.state.rects ||= [] | |
args.state.rect_size ||= 8 | |
args.state.move_squares ||= :no | |
if args.inputs.keyboard.key_down.tab | |
args.state.move_squares = args.state.move_squares == :yes ? :no : :yes | |
end | |
args.outputs.watch "FPS: #{GTK.current_framerate.to_sf}" |
Here is a minimal setup that works on Windows and Mac (yes I use Emacs on Windows and it works well).
;; using an editor you are comfortable with
;; create c:/Users/USERNAME/AppData/Roaming/.emacs.d/init.el
;; and paste these contents in there:
;; NOTE: depending on how you start up emacs, your home directory may
;; be different than the one above. Your initialization file
;; needs to be saved at ~/.emacs.d/init.el (however that is mapped
class Player | |
attr :x, :y, :w, :h, :action, :action_at, | |
:dx, :dy, :breathe_at, :facing, :run_speed, :on_ground_y, :on_ground, | |
:prev_on_ground | |
def initialize | |
@breathe_at = -100 | |
@action = :idle | |
@action_at = 0 | |
@x = 100 |