SlideShare a Scribd company logo
1 of 37
Download to read offline
Rapid Game
Development with
Ruby and Gosu
Belén Albeza
@ladybenko
Aren’t games coded in
C++?
Minecraft
(Java)
To the Moon
(RPG Maker)
So?
• Some games will require C++
• Some games won’t
• You can trade performance for:
• Better productivity (faster development,
prototypes to test ideas, etc.)

• Happiness :)
Prototyping
• One Game A Month

www.onegameamonth.com

• Experimental Gameplay

www.experimentalgameplay.com

• Ludum Dare

www.ludumdare.com
Introducing Gosu
What is Gosu?
• Gosu is a minimalistic 2D game library
www.libgosu.org

• Free, Open source (MIT License)
• Multiplatform (Win, OS X, Linux)
• Has bindings for Ruby and C++
• $gem install gosu
Gosu’s API is very small
• ~100 methods in 9 classes
• Gosu provides a way to:
• Create an OpenGL window
• Load and draw images and fonts
• Load and play sounds
• Gather player’s input
Show demo
Gosu 101

https://github.com/belen-albeza/gosu-rubymanor
The Game Loop
snippets/create_window.rb
Get player input

60 FPS

Update game

Draw game
require 'rubygems'
require 'gosu'
class Game < Gosu::Window
# ...
end
game = Game.new
game.show
class Game < Gosu::Window
def initialize
super(800, 600, false)
end
def draw # gets called every frame
end
def update # gets called every frame
end
def button_up(key) # callback
end
end
Images

snippets/draw_image.rb
Instance of Gosu::Window
# load
@img_bg =
Gosu::Image.new(self,‘space.png’)
# draw
@img_bg.draw(0, 0, 0)
@ship.draw_rot(400, 300, 0, 45)
# note: audio and fonts follow the same
# approach.
Input

snippets/input.rb
# callback for key up events
def button_up(key)
close if key == Gosu::KbEscape
end
# check if a key is being pressed
def update
if self.button_down?(Gosu::KbLeft)
move_left
end
end
Instance of Gosu::Window
Delta time

snippets/delta_time.rb
4px / frame
= 12 px
4 px

4px

4 px
= 46 ms

13 ms

4px / frame @ 60 FPS
vs
240 pixels / second

16 ms

17 ms

240 px / second
= 11.04 px
3.12 px

3.84 px

4.08 px
= 46 ms

13 ms

16 ms

17 ms
def update_delta
current_time = Gosu::milliseconds /
1000.0
# tip: always cap your delta
@delta = [current_time - @last_time,
0.25].min
@last_time = current_time
end
# simple movement
@x += SHIP_SPEED * @delta
# with inertia
@speed_x += SHIP_ACCELERATION * @delta
@x += @speed_x * @delta
Distribution
• Mac: App wrapper with a Ruby on it

https://github.com/jlnr/gosu/wiki/RubyPackaging-on-OS-X

• Windows: OCRA https://github.com/jlnr/
gosu/wiki/Ruby-Packaging-on-Windows
Game Dev Techniques
Bounding boxes
•

Quick collisions, but not
very accurate

•

Shapes can be combined
to increase accuracy

•

Beware of rotations!

http://devmag.org.za/2009/04/13/basic-collisiondetection-in-2d-part-1/
Finite State Machines
•
•
•

Patrol

Easy to implement,
cheap, lots of uses...
AI: character behaviors
Scene stack

seeing player?
not seeing player?

out of attacking distance?

Chase
Attack
in attacking distance?

http://www.generation5.org/content/2003/
fsm_tutorial.asp
Tiles
•
•

Divide a level into a grid

•

Useful to save memory,
make a level editor,
implement simple
physics, etc.

Visual grid != Logic
grid... but we can map
them :)

http://www-cs-students.stanford.edu/~amitp/
gameprog.html#tiles
Path-finding
•

They are usually very
expensive... try to
minimise their use

•

Dijkstra is enough for
simple graphs (ie. an
adventure)

•

A* for everything else
(action RPG’s, strategy,
etc.)

http://theory.stanford.edu/~amitp/GameProgramming/
Scripting
• Scripting transforms a simple arcade level

into a mission or a quest (see Cave Story)

• Embed a VM into your engine (most

popular for games is Lua)... but Ruby is
already a script language :D

• Useful triggers: enter an area, exit an area,
talk to NPC, pick up item, kill an enemy,
etc.
event = {
:type => :talk_to,
:data => :friend
}

click

call
talk_to_friend
Scripting example
# this method is called when the event
# talk_to is triggered on the :pirate
# NPC
def talk_to_pirate
npc_say(:pirate, ‘Aaaarrrr’)
add_to_inventory(:rum)
end
Physics engine
•

Real physics for your
games! Done by smart
people! And free!

•

They are slow, so try to
minimise the amount of
physical entities

•

You need to map your
visual world into an
invisible physical world
(beware of units!)
Physics + Gosu
• Use Box2D (low-level) or Chipmunk
• Chipmunk integration tutorial at https://

github.com/jlnr/gosu/wiki/Ruby-ChipmunkIntegration
The Golden Rule of Game Dev

If you can fake it,
then fake it.
Resources
• Chingu: game framework for Gosu https://
github.com/ippa/chingu

• Creative Commons art: http://

www.lostgarden.com/search/label/free
%20game%20graphics

• More: http://www.libgosu.org/cgi-bin/mwf/
board_show.pl?bid=4
Thanks!
Questions?

More Related Content

What's hot

Making an independend MMO - The Albion Online Story
Making an independend MMO - The Albion Online StoryMaking an independend MMO - The Albion Online Story
Making an independend MMO - The Albion Online StoryDavid Salz
 
Server side game_development
Server side game_developmentServer side game_development
Server side game_developmentYekmer Simsek
 
My 10 days with Phaser.js - WarsawJS Meetup #13
My 10 days with Phaser.js - WarsawJS Meetup #13My 10 days with Phaser.js - WarsawJS Meetup #13
My 10 days with Phaser.js - WarsawJS Meetup #13Piotr Kowalski
 
HTML5 Mobile Game Development Workshop - Module 2 - HTML5 Developer Conferenc...
HTML5 Mobile Game Development Workshop - Module 2 - HTML5 Developer Conferenc...HTML5 Mobile Game Development Workshop - Module 2 - HTML5 Developer Conferenc...
HTML5 Mobile Game Development Workshop - Module 2 - HTML5 Developer Conferenc...Pablo Farías Navarro
 
Unty3D Awesome Assets - uTomate
Unty3D Awesome Assets - uTomateUnty3D Awesome Assets - uTomate
Unty3D Awesome Assets - uTomateTaras Leskiv
 
Unity3D Tips and Tricks or "You are doing it wrong!"
Unity3D Tips and Tricks or "You are doing it wrong!"Unity3D Tips and Tricks or "You are doing it wrong!"
Unity3D Tips and Tricks or "You are doing it wrong!"Taras Leskiv
 
【Unite 2017 Tokyo】VRコンテンツを気持ちよくプレイさせるためのUI実装ガイド
【Unite 2017 Tokyo】VRコンテンツを気持ちよくプレイさせるためのUI実装ガイド【Unite 2017 Tokyo】VRコンテンツを気持ちよくプレイさせるためのUI実装ガイド
【Unite 2017 Tokyo】VRコンテンツを気持ちよくプレイさせるためのUI実装ガイドUnite2017Tokyo
 
Sergey Gonchar - Fast rendering with Starling
Sergey Gonchar - Fast rendering with StarlingSergey Gonchar - Fast rendering with Starling
Sergey Gonchar - Fast rendering with StarlingFlash Conference
 
WebAssembly: In a Nutshell
WebAssembly: In a NutshellWebAssembly: In a Nutshell
WebAssembly: In a NutshellRangHo Lee
 
Android game development
Android game developmentAndroid game development
Android game developmentdmontagni
 
Game dev. story
Game dev. storyGame dev. story
Game dev. storyPhenix Yu
 
Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)
Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)
Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)David Salz
 
East Coast DevCon 2014: The Slate UI Framework - Architecture & Tools
East Coast DevCon 2014: The Slate UI Framework - Architecture & ToolsEast Coast DevCon 2014: The Slate UI Framework - Architecture & Tools
East Coast DevCon 2014: The Slate UI Framework - Architecture & ToolsGerke Max Preussner
 
Game Development with Pygame
Game Development with PygameGame Development with Pygame
Game Development with PygameFramgia Vietnam
 
WebVR, not just Holograms in the web but powerful platform
WebVR, not just Holograms in the web but powerful platformWebVR, not just Holograms in the web but powerful platform
WebVR, not just Holograms in the web but powerful platformWindows Developer
 
【Unite 2017 Tokyo】大作RPGを効率的且つ高品質にリマスターするためのUnity活用
【Unite 2017 Tokyo】大作RPGを効率的且つ高品質にリマスターするためのUnity活用【Unite 2017 Tokyo】大作RPGを効率的且つ高品質にリマスターするためのUnity活用
【Unite 2017 Tokyo】大作RPGを効率的且つ高品質にリマスターするためのUnity活用Unity Technologies Japan K.K.
 

What's hot (20)

Making an independend MMO - The Albion Online Story
Making an independend MMO - The Albion Online StoryMaking an independend MMO - The Albion Online Story
Making an independend MMO - The Albion Online Story
 
Server side game_development
Server side game_developmentServer side game_development
Server side game_development
 
Introduction to Phaser.js
Introduction to Phaser.jsIntroduction to Phaser.js
Introduction to Phaser.js
 
Phaser presentation
Phaser presentationPhaser presentation
Phaser presentation
 
2011 05-jszurich
2011 05-jszurich2011 05-jszurich
2011 05-jszurich
 
My 10 days with Phaser.js - WarsawJS Meetup #13
My 10 days with Phaser.js - WarsawJS Meetup #13My 10 days with Phaser.js - WarsawJS Meetup #13
My 10 days with Phaser.js - WarsawJS Meetup #13
 
HTML5 Mobile Game Development Workshop - Module 2 - HTML5 Developer Conferenc...
HTML5 Mobile Game Development Workshop - Module 2 - HTML5 Developer Conferenc...HTML5 Mobile Game Development Workshop - Module 2 - HTML5 Developer Conferenc...
HTML5 Mobile Game Development Workshop - Module 2 - HTML5 Developer Conferenc...
 
Unty3D Awesome Assets - uTomate
Unty3D Awesome Assets - uTomateUnty3D Awesome Assets - uTomate
Unty3D Awesome Assets - uTomate
 
Unity3D Tips and Tricks or "You are doing it wrong!"
Unity3D Tips and Tricks or "You are doing it wrong!"Unity3D Tips and Tricks or "You are doing it wrong!"
Unity3D Tips and Tricks or "You are doing it wrong!"
 
Lib gdx 2015_corkdevio
Lib gdx 2015_corkdevioLib gdx 2015_corkdevio
Lib gdx 2015_corkdevio
 
【Unite 2017 Tokyo】VRコンテンツを気持ちよくプレイさせるためのUI実装ガイド
【Unite 2017 Tokyo】VRコンテンツを気持ちよくプレイさせるためのUI実装ガイド【Unite 2017 Tokyo】VRコンテンツを気持ちよくプレイさせるためのUI実装ガイド
【Unite 2017 Tokyo】VRコンテンツを気持ちよくプレイさせるためのUI実装ガイド
 
Sergey Gonchar - Fast rendering with Starling
Sergey Gonchar - Fast rendering with StarlingSergey Gonchar - Fast rendering with Starling
Sergey Gonchar - Fast rendering with Starling
 
WebAssembly: In a Nutshell
WebAssembly: In a NutshellWebAssembly: In a Nutshell
WebAssembly: In a Nutshell
 
Android game development
Android game developmentAndroid game development
Android game development
 
Game dev. story
Game dev. storyGame dev. story
Game dev. story
 
Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)
Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)
Albion Online - A Cross-Platform MMO (Unite Europe 2016, Amsterdam)
 
East Coast DevCon 2014: The Slate UI Framework - Architecture & Tools
East Coast DevCon 2014: The Slate UI Framework - Architecture & ToolsEast Coast DevCon 2014: The Slate UI Framework - Architecture & Tools
East Coast DevCon 2014: The Slate UI Framework - Architecture & Tools
 
Game Development with Pygame
Game Development with PygameGame Development with Pygame
Game Development with Pygame
 
WebVR, not just Holograms in the web but powerful platform
WebVR, not just Holograms in the web but powerful platformWebVR, not just Holograms in the web but powerful platform
WebVR, not just Holograms in the web but powerful platform
 
【Unite 2017 Tokyo】大作RPGを効率的且つ高品質にリマスターするためのUnity活用
【Unite 2017 Tokyo】大作RPGを効率的且つ高品質にリマスターするためのUnity活用【Unite 2017 Tokyo】大作RPGを効率的且つ高品質にリマスターするためのUnity活用
【Unite 2017 Tokyo】大作RPGを効率的且つ高品質にリマスターするためのUnity活用
 

Similar to Rapid Game Development with RUby and Gosu – Ruby Manor 4

Cross Game Dev with Corona
Cross Game Dev with CoronaCross Game Dev with Corona
Cross Game Dev with CoronaShawn Grimes
 
Making A Game Engine Is Easier Than You Think
Making A Game Engine Is Easier Than You ThinkMaking A Game Engine Is Easier Than You Think
Making A Game Engine Is Easier Than You ThinkGorm Lai
 
Android game development
Android game developmentAndroid game development
Android game developmentmilandinic
 
HTML5: New UI Library for Games - Chad Austin
HTML5: New UI Library for Games - Chad AustinHTML5: New UI Library for Games - Chad Austin
HTML5: New UI Library for Games - Chad AustinChad Austin
 
Developing applications and games in Unity engine - Matej Jariabka, Rudolf Ka...
Developing applications and games in Unity engine - Matej Jariabka, Rudolf Ka...Developing applications and games in Unity engine - Matej Jariabka, Rudolf Ka...
Developing applications and games in Unity engine - Matej Jariabka, Rudolf Ka...gamifi.cc
 
Confrontation Pipeline and SCons
Confrontation Pipeline and SConsConfrontation Pipeline and SCons
Confrontation Pipeline and SConsslantsixgames
 
Html5 Game Development with Canvas
Html5 Game Development with CanvasHtml5 Game Development with Canvas
Html5 Game Development with CanvasPham Huy Tung
 
iOS Game Development With UIKit
iOS Game Development With UIKitiOS Game Development With UIKit
iOS Game Development With UIKitMartin Grider
 
Adobe and the Flash Gaming Landscape
Adobe and the Flash Gaming LandscapeAdobe and the Flash Gaming Landscape
Adobe and the Flash Gaming LandscapeJoseph Labrecque
 
Game design & development
Game design & developmentGame design & development
Game design & developmentHemanth Sharma
 
Developing Multi Platform Games using PlayN and TriplePlay Framework
Developing Multi Platform Games using PlayN and TriplePlay FrameworkDeveloping Multi Platform Games using PlayN and TriplePlay Framework
Developing Multi Platform Games using PlayN and TriplePlay FrameworkCsaba Toth
 
Google App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and GaelykGoogle App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and GaelykGuillaume Laforge
 
Deploy All The Games
Deploy All The GamesDeploy All The Games
Deploy All The GamesAdam Hill
 
Looking For Xaml In All The Wrong Places
Looking For Xaml In All The Wrong PlacesLooking For Xaml In All The Wrong Places
Looking For Xaml In All The Wrong PlacesAdam Hill
 
مدخل برمجة صعيدي جيكس
مدخل برمجة صعيدي جيكس مدخل برمجة صعيدي جيكس
مدخل برمجة صعيدي جيكس Hesham Hanafi
 
W3C HTML5 KIG-The complete guide to building html5 games
W3C HTML5 KIG-The complete guide to building html5 gamesW3C HTML5 KIG-The complete guide to building html5 games
W3C HTML5 KIG-The complete guide to building html5 gamesChanghwan Yi
 

Similar to Rapid Game Development with RUby and Gosu – Ruby Manor 4 (20)

From Web to Mobile with Stage 3D
From Web to Mobile with Stage 3DFrom Web to Mobile with Stage 3D
From Web to Mobile with Stage 3D
 
Cross Game Dev with Corona
Cross Game Dev with CoronaCross Game Dev with Corona
Cross Game Dev with Corona
 
Augernaut js
Augernaut jsAugernaut js
Augernaut js
 
Making A Game Engine Is Easier Than You Think
Making A Game Engine Is Easier Than You ThinkMaking A Game Engine Is Easier Than You Think
Making A Game Engine Is Easier Than You Think
 
Android game development
Android game developmentAndroid game development
Android game development
 
HTML5: New UI Library for Games - Chad Austin
HTML5: New UI Library for Games - Chad AustinHTML5: New UI Library for Games - Chad Austin
HTML5: New UI Library for Games - Chad Austin
 
Developing applications and games in Unity engine - Matej Jariabka, Rudolf Ka...
Developing applications and games in Unity engine - Matej Jariabka, Rudolf Ka...Developing applications and games in Unity engine - Matej Jariabka, Rudolf Ka...
Developing applications and games in Unity engine - Matej Jariabka, Rudolf Ka...
 
Confrontation Pipeline and SCons
Confrontation Pipeline and SConsConfrontation Pipeline and SCons
Confrontation Pipeline and SCons
 
cadec-2017-golang
cadec-2017-golangcadec-2017-golang
cadec-2017-golang
 
Html5 Game Development with Canvas
Html5 Game Development with CanvasHtml5 Game Development with Canvas
Html5 Game Development with Canvas
 
iOS Game Development With UIKit
iOS Game Development With UIKitiOS Game Development With UIKit
iOS Game Development With UIKit
 
Adobe and the Flash Gaming Landscape
Adobe and the Flash Gaming LandscapeAdobe and the Flash Gaming Landscape
Adobe and the Flash Gaming Landscape
 
Game design & development
Game design & developmentGame design & development
Game design & development
 
Developing Multi Platform Games using PlayN and TriplePlay Framework
Developing Multi Platform Games using PlayN and TriplePlay FrameworkDeveloping Multi Platform Games using PlayN and TriplePlay Framework
Developing Multi Platform Games using PlayN and TriplePlay Framework
 
Creating Casual Games for Windows 8
Creating Casual Games for Windows 8Creating Casual Games for Windows 8
Creating Casual Games for Windows 8
 
Google App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and GaelykGoogle App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and Gaelyk
 
Deploy All The Games
Deploy All The GamesDeploy All The Games
Deploy All The Games
 
Looking For Xaml In All The Wrong Places
Looking For Xaml In All The Wrong PlacesLooking For Xaml In All The Wrong Places
Looking For Xaml In All The Wrong Places
 
مدخل برمجة صعيدي جيكس
مدخل برمجة صعيدي جيكس مدخل برمجة صعيدي جيكس
مدخل برمجة صعيدي جيكس
 
W3C HTML5 KIG-The complete guide to building html5 games
W3C HTML5 KIG-The complete guide to building html5 gamesW3C HTML5 KIG-The complete guide to building html5 games
W3C HTML5 KIG-The complete guide to building html5 games
 

Recently uploaded

#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

Rapid Game Development with RUby and Gosu – Ruby Manor 4

  • 1. Rapid Game Development with Ruby and Gosu Belén Albeza @ladybenko
  • 5. So? • Some games will require C++ • Some games won’t • You can trade performance for: • Better productivity (faster development, prototypes to test ideas, etc.) • Happiness :)
  • 6. Prototyping • One Game A Month www.onegameamonth.com • Experimental Gameplay www.experimentalgameplay.com • Ludum Dare www.ludumdare.com
  • 8. What is Gosu? • Gosu is a minimalistic 2D game library www.libgosu.org • Free, Open source (MIT License) • Multiplatform (Win, OS X, Linux) • Has bindings for Ruby and C++ • $gem install gosu
  • 9. Gosu’s API is very small • ~100 methods in 9 classes • Gosu provides a way to: • Create an OpenGL window • Load and draw images and fonts • Load and play sounds • Gather player’s input
  • 13. Get player input 60 FPS Update game Draw game
  • 14. require 'rubygems' require 'gosu' class Game < Gosu::Window # ... end game = Game.new game.show
  • 15. class Game < Gosu::Window def initialize super(800, 600, false) end def draw # gets called every frame end def update # gets called every frame end def button_up(key) # callback end end
  • 17. Instance of Gosu::Window # load @img_bg = Gosu::Image.new(self,‘space.png’) # draw @img_bg.draw(0, 0, 0) @ship.draw_rot(400, 300, 0, 45) # note: audio and fonts follow the same # approach.
  • 18.
  • 20. # callback for key up events def button_up(key) close if key == Gosu::KbEscape end # check if a key is being pressed def update if self.button_down?(Gosu::KbLeft) move_left end end Instance of Gosu::Window
  • 22. 4px / frame = 12 px 4 px 4px 4 px = 46 ms 13 ms 4px / frame @ 60 FPS vs 240 pixels / second 16 ms 17 ms 240 px / second = 11.04 px 3.12 px 3.84 px 4.08 px = 46 ms 13 ms 16 ms 17 ms
  • 23. def update_delta current_time = Gosu::milliseconds / 1000.0 # tip: always cap your delta @delta = [current_time - @last_time, 0.25].min @last_time = current_time end # simple movement @x += SHIP_SPEED * @delta # with inertia @speed_x += SHIP_ACCELERATION * @delta @x += @speed_x * @delta
  • 24. Distribution • Mac: App wrapper with a Ruby on it https://github.com/jlnr/gosu/wiki/RubyPackaging-on-OS-X • Windows: OCRA https://github.com/jlnr/ gosu/wiki/Ruby-Packaging-on-Windows
  • 26. Bounding boxes • Quick collisions, but not very accurate • Shapes can be combined to increase accuracy • Beware of rotations! http://devmag.org.za/2009/04/13/basic-collisiondetection-in-2d-part-1/
  • 27. Finite State Machines • • • Patrol Easy to implement, cheap, lots of uses... AI: character behaviors Scene stack seeing player? not seeing player? out of attacking distance? Chase Attack in attacking distance? http://www.generation5.org/content/2003/ fsm_tutorial.asp
  • 28. Tiles • • Divide a level into a grid • Useful to save memory, make a level editor, implement simple physics, etc. Visual grid != Logic grid... but we can map them :) http://www-cs-students.stanford.edu/~amitp/ gameprog.html#tiles
  • 29. Path-finding • They are usually very expensive... try to minimise their use • Dijkstra is enough for simple graphs (ie. an adventure) • A* for everything else (action RPG’s, strategy, etc.) http://theory.stanford.edu/~amitp/GameProgramming/
  • 30. Scripting • Scripting transforms a simple arcade level into a mission or a quest (see Cave Story) • Embed a VM into your engine (most popular for games is Lua)... but Ruby is already a script language :D • Useful triggers: enter an area, exit an area, talk to NPC, pick up item, kill an enemy, etc.
  • 31. event = { :type => :talk_to, :data => :friend } click call talk_to_friend
  • 32. Scripting example # this method is called when the event # talk_to is triggered on the :pirate # NPC def talk_to_pirate npc_say(:pirate, ‘Aaaarrrr’) add_to_inventory(:rum) end
  • 33. Physics engine • Real physics for your games! Done by smart people! And free! • They are slow, so try to minimise the amount of physical entities • You need to map your visual world into an invisible physical world (beware of units!)
  • 34. Physics + Gosu • Use Box2D (low-level) or Chipmunk • Chipmunk integration tutorial at https:// github.com/jlnr/gosu/wiki/Ruby-ChipmunkIntegration
  • 35. The Golden Rule of Game Dev If you can fake it, then fake it.
  • 36. Resources • Chingu: game framework for Gosu https:// github.com/ippa/chingu • Creative Commons art: http:// www.lostgarden.com/search/label/free %20game%20graphics • More: http://www.libgosu.org/cgi-bin/mwf/ board_show.pl?bid=4