SlideShare ist ein Scribd-Unternehmen logo
1 von 37
Downloaden Sie, um offline zu lesen
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?

Weitere ähnliche Inhalte

Was ist angesagt?

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.
 

Was ist angesagt? (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活用
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 

Kürzlich hochgeladen (20)

"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 

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