Skip to content

Instantly share code, notes, and snippets.

💭
Working on a Ruby runtime for building apps and games 🎉 :wq

Amir Rajan amirrajan

💭
Working on a Ruby runtime for building apps and games 🎉 :wq
Block or report user

Report or block amirrajan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@amirrajan
amirrajan / main.rb
Last active Sep 17, 2019
Vertical space shooter in DragonRuby Game Toolkit
View main.rb
def new_enemy args
{ x: 1280.randomize(:ratio),
starting_y: 800,
final_distance: 900,
duration: 60.randomize(:ratio) + 180,
created_at: args.state.tick_count,
size: 32,
fire_rate: (30.randomize(:ratio) + (60 - args.state.score)).to_i }
end
@amirrajan
amirrajan / main.rb
Created Sep 15, 2019
Vertical Platformer Written in DragonRuby Game Toolkit
View main.rb
class VerticalPlatformer
gtk_args
def inputs
args.inputs
end
def s
state.vertical_platformer ||= state.new_entity(:vertical_platformer)
state.vertical_platformer
@amirrajan
amirrajan / main.rb
Created Sep 15, 2019
Tic Tac Toe Written in DragonRuby Game Toolkit
View main.rb
#This sample app is a classic game of Tic Tac Toe.
class TicTacToe
attr_accessor :_, :state, :outputs, :inputs, :grid, :gtk
#Starts the game with player x's turn and creates an array for space combinations.
#Calls methods necessary for the game to run properly.
def tick
state.current_turn ||= :x
state.space_combinations = [-1, 0, 1].product([-1, 0, 1]).to_a
@amirrajan
amirrajan / main.rb
Last active Sep 7, 2019
DragonRuby Game Toolkit Sprite Sheet Example
View main.rb
def tick args
args.labels << [640, 689, "Asset Presenter", 0, 1]
args.sprites << tile(0, 0, 100, 100)
args.sprites << tile(1, 0, 200, 200)
args.sprites << tile(2, 0, 300, 300)
10.map_with_index do |x|
10.map_with_index do |y|
args.sprites << tile(x, y, 30 + x * 64, 30 + y * 64)
end
View bowser.rb
def fiddle args
args.state.gravity = -0.3
args.state.enemy_jump_power = 10
args.state.enemy_jump_interval = 60
args.state.hammer_throw_interval = 40
args.state.hammer_launch_power_default = 5
args.state.hammer_launch_power_near = 2
args.state.hammer_launch_power_far = 7
args.state.hammer_upward_launch_power = 15
args.state.max_hammers_per_volley = 10
@amirrajan
amirrajan / pong.rb
Last active Aug 28, 2019
Pong in DragonRuby Game Toolkit
View pong.rb
def tick args
defaults args
render args
calc args
input args
end
def defaults args
args.state.ball.debounce ||= 3 * 60
args.state.ball.size ||= 10
View label_example.rb
def tick args
# change the code and save,
# you silly goose you
args.outputs.labels << [
640,
360,
"Hello World.",
big_font,
center_align
]
View lowrez.rb
# https://twitter.com/hashtag/LOWREZJAM
###################################################################################
# YOUR GAME GOES HERE
###################################################################################
def lowrez_tick args, lowrez_sprites, lowrez_labels, lowrez_borders, lowrez_solids, lowrez_mouse
# args.state.show_gridlines = true
if args.state.you_win
lowrez_tick_you_win args, lowrez_labels
View snakemoji.rb
# coding: utf-8
################################
# So I was working on a snake game while
# learning DragonRuby, and at some point I had a thought
# what if I use "😀" as a function name, surely it wont work right...?
# RIGHT....?
# BUT IT DID, IT WORKED
# it all went downhill from then
# Created by Anton K. (ai Doge)
# https://gist.github.com/scorp200
@amirrajan
amirrajan / main.rb
Last active Aug 17, 2019
Default gist for fiddle.dragonruby.org
View main.rb
def tick args
args.outputs.labels << [640, 360, "Hello World.", 0, 1]
end
You can’t perform that action at this time.