SlideShare a Scribd company logo
1 of 94
Download to read offline
High A!
              on top of

   Low-level APIs
     Building Games with Ruby




Andrea O. K. Wright, Chariot Solutions
     www.chariotsolutions.com
High A!
                        on top of

          Low-level APIs
            Building Games with Ruby
                     Agenda
1.           Buiding 2D Games with Ruby

2.           Building 3D Games with Ruby

3.   Is Ruby a legitimate player in the gaming space?
Creator and Lead Developer: Ohai
http://www.kmc.gr.jp/~ohai/rubysdl.en.html
C Extension

Uint32 SDL_GetTicks(void);
C Extension

Uint32 SDL_GetTicks(void);




static VALUE sdl_getTicks(VALUE mod)
{
  return UINT2NUM(SDL_GetTicks());
}
C Extension

Uint32 SDL_GetTicks(void);




static VALUE sdl_getTicks(VALUE mod)
{
  return UINT2NUM(SDL_GetTicks());
}

 rb_define_module_function(mSDL,
              "getTicks", sdl_getTicks,0);
C Extension

Uint32 SDL_GetTicks(void);




static VALUE sdl_getTicks(VALUE mod)
{
  return UINT2NUM(SDL_GetTicks());
}

  rb_define_module_function(mSDL,
               "getTicks", sdl_getTicks,0);

                  alias get_ticks getTicks
Samples
Samples




screen = SDL::setVideoMode(640,480,16,SDL::SWSURFACE)
                                      SDL::HWSURFACE

                                       SDL::OPENGL
Sample
Introducing Sprites
sprites = []
for i in 1..5
  sprites << Sprite.new
end
sprites << MovableSp.new
Sample Event Loop
while true
  while event = SDL::Event2.poll
    case event
    when SDL::Event2::Quit
      exit
    when SDL::Event2::KeyDown
      exit if event.sym == SDL::Key::ESCAPE
    end
  end
  screen.fillRect(0,0,640,480,0)
  SDL::Key.scan
  sprites.each {|i|
    i.move
    i.draw(screen)
  }
  screen.updateRect(0,0,0,0)
end
Sprite: Random Motion
class Sprite
  def initialize
    @x=rand(640)
    ...
    @dx=rand(11)-5
  end
  def move
    @x += @dx
    if @x >= 640 then
      @dx *= -1
      @x = 639
    end
    if @x < 0 then
      @dx *= -1
      @x = 0
    end
    ...
  end
  def draw(screen)
    SDL.blitSurface($image,0,0,32,32,screen,@x,@y)
  end
end
Event-Driven Sprite
class MovableSp
  def initialize()
    @ud=@lr=0;
  end
  def move()
    @ud=@lr=0;
    @lr=-1 if SDL::Key.press?(SDL::Key::LEFT)
    @lr=1 if SDL::Key.press?(SDL::Key::RIGHT)
    @ud=1 if SDL::Key.press?(SDL::Key::DOWN)
    @ud=-1 if SDL::Key.press?(SDL::Key::UP)
  end
  def draw(screen)
    SDL.blitSurface($image,0,0,32,32,
    screen,300+@lr*50,200+@ud*50)
  end
end
Steven Davidovitz’s Nebular Gauntlet




             Project Home: http://www.nebulargauntlet.org/
Steven Davidovitz’s Nebular Gauntlet




            while !@@quit
              handle_input() # Handle keyboard input
              do_think() # Do calculations/thinking
              do_render() # Render everything
              Signal.trap("INT", @on_quit)
              Signal.trap("EXIT", @on_quit)
            end




Project Home: http://www.nebulargauntlet.org/
Steven Davidovitz’s Nebular Gauntlet
class Radar < Box
  def initialize(screen, size_modifier, *objects)
    @size = size_modifier
    height = $map.h / @size
    width = $map.w / @size
    super(screen, height, width)
    @objects = objects
  end
  def draw
    @screen.drawRect(@x, @y, @width, @height, @bcol)
    @objects.each do |obj|
    @screen.drawFilledCircle(0 + (obj.x / @size,
        0 + (obj.y / @size), 2, [200, 200, 200])
        if obj.state == :alive
    end
  end
end
Project Home: http://www.nebulargauntlet.org/
Danny Van Bruggen, Creator
http://sourceforge.net/projects/rudl/
Principle of Least Surprise?


SDL_Surface *SDL_SetVideoMode(int width, int height,
                              int bpp,Uint32 flags);




static VALUE displaySurface_new(int argc, VALUE* argv,
                                VALUE self)
Principle of Least Surprise?

screen = SDL::setVideoMode(640,480,16,SDL::SWSURFACE)




display = DisplaySurface.new([640,480])
Principle of Least Surprise?
static VALUE sdl_setVideoMode(VALUE mod,VALUE w,VALUE h,
    VALUE bpp,VALUE flags){
  SDL_Surface *screen;
  screen = SDL_SetVideoMode(NUM2INT(w),NUM2INT(h, NUM2IN
         (bpp), NUM2UINT(flags));
  if(screen == NULL){
    rb_raise(eSDLError,
      "Couldn't set %dx%d %d bpp video mode:%s",
      NUM2INT(w),NUM2INT(h),NUM2INT(bpp),SDL_GetError());
  }
  return Data_Wrap_Struct(cScreen,0,0,screen);
}

rb_define_module_function(mSDL, "setVideoMode",
sdl_setVideoMode,4);
Principle of Least Surprise?

static VALUE displaySurface_new(int argc, VALUE*
argv, VALUE self)
{
   ...
   surf = SDL_SetVideoMode(w, h, depth, flags);
   currentDisplaySurface = Data_Wrap_Struct
     (classDisplaySurface, 0, 0, surf);
   return currentDisplaySurface;
})

rb_define_singleton_method(classDisplaySurface,
                           "new",
                           displaySurface_new,
                           -1);
Principle of Least Surprise?

screen = SDL::setVideoMode(640,480,16,SDL::SWSURFACE)




display = DisplaySurface.new([640,480])
OpenGL


            http://nehe.gamedev.net/




RUDL Ports of Neon Helium Tutorials, Packaged with RUDL,
Ported by Martin Stannard
OpenGL
def init(w,h)
  GL.ClearColor(0.0, 0.0, 0.0, 0.0)
  GL.ClearDepth(1.0)
  GL.DepthFunc(GL::LESS)
  GL.Enable(GL::DEPTH_TEST)
  GL.ShadeModel(GL::SMOOTH)
  GL.MatrixMode(GL::PROJECTION)
  GL.LoadIdentity()
  GLU.Perspective(45.0, w.to_f/h.to_f,
     0.1, 100.0)
  GL.MatrixMode(GL::MODELVIEW)
  GL.LoadIdentity()
  GLU.LookAt(0.0, 0.0, 5.0,
    0.0, 0.0, 0.0, 0.0, 1.0,
    0.0)
end


                                 Source by Martin Stannard: from RUDL samples
OpenGL
    display = Proc.new {
    GL.Clear(GL::COLOR_BUFFER_BIT|
             GL::DEPTH_BUFFER_BIT)
    GL.Color(1.0, 1.0, 1.0)
    GL.LoadIdentity()
    GL.Translate(-1.5, 0.0, -6.0)
    # draw a triangle
    GL.Begin(GL::POLYGON)
    GL.Color3f(1.0, 0.0, 0.0)
    GL.Vertex3f(0.0, 1.0, 0.0)
    GL.Color3f(0.0, 1.0, 0.0)
    GL.Vertex3f(1.0,-1.0, 0.0)
    GL.Color3f(0.0, 0.0, 1.0)
    GL.Vertex3f(-1.0,-1.0, 0.0)
    GL.End()
    GL.Translate(3.0,0.0,0.0)
}

                                Source by Martin Stannard: from RUDL samples
Creator and Lead Developer: John Croisant
 http://rubygame.sourceforge.net/info.html
and




Sample Packaged with Rubygame
and




Sample Packaged with Rubygame
and

Rect
and

                         Rect
                left    centerx    right
              (x, y)    midtop
                                              top
            topleft                topright
             midleft              midright
centery
                        center
          bottomleft            bottomright
                                          bottom
                       midbottom
              @rect.topleft = 10,10
and

                        Rect




# Attempt to punch a target.
# Returns true if it hit or false if not.
def punch(target)
  @punching = true
  return @rect.inflate(-5,-5).collide_rect?(target.rect)
end
and

Sprites::Sprite, Sprites::Groups,
    Sprites::UpdateGroups




  Sample Packaged with Rubygame
Edge
Edge                    Scene Management




 Sample Packaged with the Development 3.0.0 branch
Edge                      and



 ruby = GLImageSprite.new {
   @surface = Surface.load_image('ruby.png')
   setup_texture()
   @pos = Vector2[100,300]
   @depth = -0.1
   @angle = -0.2
 }
Edge
Co-Creators: Julian Raschke & Jan Lücker
    Lead Developer: Julian Raschke
    http://code.google.com/p/gosu/
Tutorial
Main Window
class MainWindow < Gosu::Window
  def initialize(width, height, fullscreen)
    super
  end
 def update
   # Change display attributes, if necessary.
 def draw
   # Display calls go here.
 end
  def button_down(id)
    # Buttons are keys, mouse buttons, and
    # game pad controls.
  end
end
w = MyWindow.new(640, 480, false)
w.show
Techniques
class Star
  attr_reader :x, :y
  def initialize(animation)
    @animation = animation
    @color = Gosu::Color.new(0xff000000)
    @color.red = rand(255 - 40) + 40
    @color.green = rand(255 - 40) + 40
    @color.blue = rand(255 - 40) + 40
    @x = rand * 640
    @y = rand * 480
  end
  def draw
    img =
      @animation[Gosu::milliseconds/100 % @animation.size]
    img.draw(@x - img.width/2.0, @y - img.height/2.0,
        ZOrder::Stars, 1, 1, @color, :additive)
  end
end
Nightly Travels of a Witch




Team Tortilla: Florian Gross, Julian Raschke, Alexander Post
and

wiki.slembcke.net/main/published/Chipmunk
  Creator and Developer: Scott Lembcke




        Sample Packaged with Chipmunk
and

if rand(100) < 4 and @stars.size < 25 then

 body = CP::Body.new(0.0001, 0.0001)
 shape = CP::Shape::Circle.new(body, 25/2,
   CP::Vec2.new(0.0, 0.0))
 shape.collision_type = :star
 @space.add_body(body)
 @space.add_shape(shape)

  stars.push(Star.new(@star_anim, shape))
end




      GosuChipmunk Tutorial by Dirk Johnson
and




Based on a Tutorial By Dirk Johnson
and




Sample Packaged with Gosu
and
def remove_dirt point, radius
  $playfield_buffer.filled_circle([point[0],
     point[1]], radius, [0,0,0])
  $backbuffer.filled_circle([point[0],point[1]],
    radius, [0,0,0])
end




            Sample Packaged with RUDL
 “Barrage” by Brian Palmer, Pocket Martian Software
and

if not @crater_image then
  @crater_image = Magick::Image.new(50, 50)
    {self.background_color = 'none'}
  gc = Magick::Draw.new
  gc.fill('black').circle(25, 25, 25, 0)
  gc.draw(@crater_image)
  @crater_shadow = @crater_image.shadow(0,0,5,1)
end




    @crater_image       @crater_shadow
and

@rmagick_images[index].composite!(@crater_shadow,
  center_x - 35, center_y - 35,
  Magick::AtopCompositeOp)




@rmagick_images[index].composite!(@crater_image,
  center_x - 25, center_y - 25,
           @crater_image          @crater_shadow
  Magick::DstOutCompositeOp)




@gosu_images[index] = Gosu::Image.new(@window,
 @rmagick_images[index], true)
and

def draw
  gl do
    glClearColor(0.0, 0.2, 0.5, 1.0)
    glClearDepth(0)
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
    @gl_background.exec_gl
  end
  ...
end
and




Sample Packaged with Gosu
and

def exec_gl
  info = @image.gl_tex_info
  ...
    0.upto(POINTS_Y - 2) do |y|
      0.upto(POINTS_X - 2) do |x|
        glBegin(GL_TRIANGLE_STRIP)
          z = @height_map[y][x]
          glColor4d(1, 1, 1, z)
          glTexCoord2d(info.left, info.top)
          glVertex3d(-0.5 + (x - 0.0) / (POINTS_X-1),
            -0.5 + (y - offs_y - 0.0) / (POINTS_Y-2),
            z)
          ...
        glEnd
      end
    end
end
Creator and Lead Developer:
             Jason Roelofs
http://ogrerb.rubyforge.org/index.html
Samples
Shattered Ruby
   Co-Creators and Co-Lead Developers:
     Martyn Garcia and Mikkel Garcia
http://groups.google.com/group/shatteredruby
Shattered Ruby




Shattered Tetris Tutorial
Shattered Ruby
Martyn Garcia on Shattered Ruby vs. Rails



“...while Rails has a simple text output view,
Shattered has a very complex 3d rendering. And
while Shattered has simple game logic, Rails has a
very complex database backend.
Our focus is swapped.
The way Rails gains a ton of power is by making
assumptions on the model. ..[o]ur view is the
largest part...”
ShatteredRuby
From the Ogre.rb Samples
class SkyPlaneApplication < Application
  def create_scene
    scene_manager.set_ambient_light ColourValue.new(0.5,
       0.5, 0.5)
    plane = Plane.new
    plane.d = 5000
    plane.normal = -Vector3.UNIT_Y
    scene_manager.set_sky_plane(true,
       plane,"SpaceSkyPlane", 10000, 3)
    light = scene_manager.create_light("MainLight")
    light.set_position(20, 80, 50)
    dragon = scene_manager.create_entity("dragon",
       "dragon.mesh")
    scene_manager.root_scene_node.attach_object(dragon)
  end
end
ShatteredRuby
From the Ogre.rb Samples
class SkyPlaneApplication < Application
  def create_scene
    scene_manager.set_ambient_light ColourValue.new(0.5,
       0.5, 0.5)
    plane = Plane.new
    Shattering the Code....
    plane.d = 5000
    plane.normal = -Vector3.UNIT_Y
    scene_manager.set_sky_plane(true,
       plane,"SpaceSkyPlane", 10000, 3)
       class SkyPlane
    light = scene_manager.create_light("MainLight")
    light.set_position(20, 80, 50)
         light “Mainlight”,
    dragon = scene_manager.create_entity("dragon",
                :position => (20,80,50)
       "dragon.mesh")
       end
    scene_manager.root_scene_node.attach_object(dragon)
  end class Dragon
end
       end
Shattered Ruby
  Symbols to Vector

:x.to_v          #v(1,0,0)
:y.to_v          #v(0,1,0)
:z.to_v          #v(0,0,1)
:up.to_v         #v(0,1,0)
:down.to_v       #v(0,-1,0)
:left.to_v       #v(-1,0,0)
:right.to_v      #v(1,0,0)
:forward.to_v    #v(0,0,1)
:backward.to_v   #v(0,0,-1)
:zero.to_v       #v(0,0,0)
Shattered Ruby Timers
class Bomb < ...
  timer :in => 30.seconds,
        :action => :blow_up
  timer :every => 1.second,
        :action => :shorten_fuse
  def blow_up
  ...
  end
  def shorten_fuse
  ...
  end
end



           from the Shattered Wiki: http://wiki.shatteredruby.com/index.php?title=Timers
ShatteredRuby
> shatter space_race
Shattered Ruby
> shatter space_race
  create   app/models
  create   app/views
  create   app/media/common/programs
  create   app/media/common/templates
  create   doc
  create   config
  create   log
  create   script
  create   test/unit
  create   vendor
  create   vendor/plugins
  create   Rakefile
  create   README
  create   config/ogre_plugins.windows.cfg
  create   config/ogre.cfg
  create   config/boot.rb
  create   config/environment.rb
  create   test/test_helper.rb
  create   script/generate
  create   script/runner
  create   script/console
  ...
ShatteredRuby
          ModelViewActor Architecture
                                                               Actor
space_race>script/generate actor flying_carpet
      exists app/models/
      exists test/unit/                      Model
      create app/models/flying_carpet.rb
      create test/unit/flying_carpet_test.rb
      exists app/views/
      create app/media/flying_carpet              View
      create app/views/flying_carpet_view.rb
      create app/media/flying_carpet/flying_carpet.mesh
      create app/media/flying_carpet/flying_carpet.png

Model
Contains game logic and handles user input events.
When a method is called on the Model, and a method with the same
name exists on the View -- the View’s method is automatically invoked.
View
The View responds to methods on the Model.
ShatteredRuby
                    State Management
space_race>script/generate state menu
      create app/states/
      create app/states/menu_state.rb

space_race>script/generate state game
      exists app/states/
      create app/states/game_state.rb


State
Represents routes through the application
Provides a top level where actors can interact
ShatteredRuby
 OGRE Materials Format
 // This is a comment
 material walls/funkywall1
 {
    // first, preferred technique
    technique
    {
        // first pass
        pass
        {
            ambient 0.5 0.5 0.5
            diffuse 1.0 1.0 1.0
 
      
        
            // Texture unit 0
            texture_unit
            {
                texture wibbly.jpg
                scroll_anim 0.1 0.0
                wave_xform scale sine 0.0 0.7 0.0 1.0
            }
            // Texture unit 1 (this is a multitexture pass)
            texture_unit
            {
                texture wobbly.png
                rotate_anim 0.25
                colour_op add
            }
        }
    }

   // Second technique, can be used as a fallback or LOD level
   technique
   {
      // .. and so on
   }
 
     
 }


 (from the OGRE manual:
http://www.ogre3d.org/docs/manual/manual_14.html)
Shattered Ruby Rmaterials
                material < %= name % >
OGRE Materials Format
                {
  // This is a comment

                     technique
  material walls/funkywall1
  {

                     {
     // first, preferred technique
     technique
     {
         // first pass
         pass            pass
         {
                         {
             ambient 0.5 0.5 0.5
             diffuse 1.0 1.0 1.0
  
      
        
        lighting off
             // Texture unit 0
             texture_unit
             {             texture_unit
                           {
                 texture wibbly.jpg
                 scroll_anim 0.1 0.0
                 wave_xform scale sine 0.0 0.7 0.0 1.0
             }                 texture < %= texture % >
             // Texture unit 1 (this is a multitexture pass)
             texture_unit
             {             }
                       }
                 texture wobbly.png
                 rotate_anim 0.25
                 colour_op add

         }
             }
                   }
     }
                }
    // Second technique, can be used as a fallback or LOD level
    technique
    {
       // .. and so on
    }
  
     
material :flying_carpet, :template => 'basic',
  }

   (from the OGRE manual:
                   :texture => 'tapestry.png'
  http://www.ogre3d.org/docs/manual/manual_14.html)
Shattered Ruby




Shattered Tetris Tutorial
Shattered Ruby



That’s right, there are no more “What, Shattered
doesn’t support per vertex bi-quadruple render
transmutation?! -- that’s outragous!”. Anything
supported in Ogre will be supported in Shattered!
                            -- Mikkel Garcia
Shattered Ruby Tutorial




http://wiki.shatteredruby.com/
Shattered Ruby
Shattered Ruby
    Co-Creators and Co-Lead Developers:
        Martyn Garcia and Mikkel Garcia
http://groups.google.com/group/shatteredruby
Creator and Lead Developers: David Koontz
   http://rubyforge.org/projects/railgun/
High A!
                        on top of

          Low-level APIs
            Building Games with Ruby
                     Agenda
1.           Buiding 2D Games with Ruby

2.           Building 3D Games with Ruby

3.   Is Ruby a legitimate player in the gaming space?
The GGZ Gaming Zone Project




Founders: Brent M. Hendricks and Rich Gade
        Developed & Maintained by
          an International Team
      http://www.ggzgamingzone.org/
GGZ Gaming Zone
http://games.ggzcommunity.org/




           http://live.ggzgamingzone.org:5688/
                                localhost:5688/
GGZ Gaming Zone




GGZ GTK+ Core Client



                       GGZ KDE Core Client
GGZ Gaming Zone
GGZ Gaming Zone
Iagno, GNOME Games
GGZ Gaming Zone
                         ggzcommgen
game client net.c                     net.c
                                            game server
             Game Client/Game Server (tictactoe)
                  Individual Protocol
                  TCP/IP or UDP/IP
ggzmod/game                                ggzdmod/server

Game Client/Core Client         Game Server/GGZ Server
Binary Protocol                             Binary Protocol
Local Connection                          Local Connection


ggzmod/core                                  ggzmod/core
core client      Core Client/GGZ Server      ggz server
                      XML Protocol
                          TCP/IP
              ggzcore
GGZ Gaming Zone
game client         Game Client to
                     Core Client
               GAME_STATE(0), STAND(1), SIT(2),
ggzmod/game      BOOT(3), BOT(4), OPEN(5),
                         CHAT(6)
                     Core Client to
                      Game Client
ggzmod/core
              GAME_LAUNCH(0), GAME_SERVER(1),
core client    GAME_PLAYER (2), GAME_SEAT(3),
core client       GAME_SPECTATOR SEAT(4)
                GAME_CHAT(5), GAME_STATS(6)
GGZ Gaming Zone
game client        Game Client to
                 DATA             TYPE
                     Core Client
                 Opcode             4
               GAME_STATE(0), STAND(1), SIT(2),
ggzmod/game       BOOT(3), BOT(4), OPEN(5),
               Spectator Seat#
                           CHAT(6) integer
              Spectator Name    string
                     Core Client to
                      Game Client
ggzmod/core
              GAME_LAUNCH(0), GAME_SERVER(1),
core client    GAME_PLAYER (2), GAME_SEAT(3),
core client    GAME_SPECTATOR SEAT(4)
                GAME_CHAT(5), GAME_STATS(6)
GGZ Gaming Zone
                         ggzcommgen
game client net.c                     net.c
                                            game server
             Game Client/Game Server (tictactoe)
                  Individual Protocol
                  TCP/IP or UDP/IP
ggzmod/game                                ggzdmod/server

Game Client/Core Client         Game Server/GGZ Server
Binary Protocol                             Binary Protocol
Local Connection                          Local Connection


ggzmod/core                                  ggzmod/core
core client     Core Client/GGZ Server       ggz server
                      XML Protocol
                         TCP/IP
              ggzcore
GGZ Gaming Zone
                     ggzcommgen
game client net.c                     net.c
                                            game server
             Game Client/Game Server (tictactoe)
                  Individual Protocol
                  TCP/IP or UDP/IP
   <ggzcomm engine="tictactoe" version="4">
     <definitions>
       <def name="msggameover" value="3"/>
     </definitions>
     <server>
     ...
        <event name="msggameover">
          <data name="winner" type="byte"/>
        </event>
     </server>
   </ggzcomm>
GGZ Gaming Zone
                     ggzcommgen
game client net.c                     net.c
                                            game server
             Game Client/Game Server (tictactoe)
                  Individual Protocol
                  TCP/IP or UDP/IP
   <ggzcomm engine="tictactoe" version="4">
      <definitions>
    void ggzcomm_msggameover(GGZCommIO * io) {
            <def name="msggameover" value="3"/>
       ret = ggz_write_int(io->fd, msggameover);
        </definitions>
       if(ret < 0)
      <server>
      ... ggzcomm_error();
       ret = ggz_write_char(io >fd,variables.winner);
         <event name="msggameover">
       if(ret < 0)name="winner" type="byte"/>
            <data
          ggzcomm_error();
         </event>
    }
      </server>
   </ggzcomm>
GGZ Gaming Zone
                        ggzcommgen
              net.rb                 net.rb
   Ruby          Game Client/Game Server         Ruby
game client          Individual Protocol      game server
                     TCP/IP or UDP/IP
    <ggzcomm engine="tictactoe" version="4">
      <definitions>
            <def name="msggameover" value="3"/>
def send_gameover(p, winner)
  ...   </definitions>
  s = <server>
      GGZRawSocket.for_fd($server.get_seat_fd(p))
      ...
         <event name="msggameover">
  s.puti(::MSG_GAMEOVER)
  s.putb(winner) name="winner" type="byte"/>
           <data
end      </event>
     </server>
    </ggzcomm>
GGZ Gaming Zone
                         ggzcommgen
              net.rb                  net.rb      Ruby
  Ruby
game client Game Client/Game Server            game server
                Individual Protocol
                TCP/IP or UDP/IP
ggzmod/game       ruggzmod/     ruggzdmod      ggzdmod/server
                  RGGZMod
Game Client/Core Client         Game Server/GGZ Server
Binary Protocol                             Binary Protocol
Local Connection                          Local Connection

ggzmod/core                                     ggzmod/core
core client     Core Client/GGZ Server          ggz server
                      XML Protocol
                         TCP/IP
              ggzcore
GGZ Gaming Zone
                         ggzcommgen
              net.rb                  net.rb

 QtRuby
               Game Client/Game Server
                   Individual Protocol
                                               rubytoe
                                                game server
   game client     TCP/IP or UDP/IP
ggzmod/game       ruggzmod/     ruggzdmod      ggzdmod/server
                  RGGZMod
Game Client/Core Client         Game Server/GGZ Server
Binary Protocol                             Binary Protocol
Local Connection                          Local Connection

ggzmod/core                                     ggzmod/core
core client     Core Client/GGZ Server          ggz server
                      XML Protocol
                         TCP/IP
              ggzcore
GGZ Gaming Zone
                        ggzcommgen
              net.rb                 net.rb

 QtRuby
               Game Client/Game Server
                   Individual Protocol
                                              rubytoe
                                               game server
   game client     TCP/IP or UDP/IP
ggzmod/game       ruggzmod/    ruggzdmod      ggzdmod/server
                  RGGZMod
Game Client/Core Client        Game Server/GGZ Server
Binary Protocol                            Binary Protocol
Local Connection                         Local Connection

ggzmod/core                                    ggzmod/core
core client     Core Client/GGZ Server         ggz server
                      XML Protocol
                         TCP/IP
              ggzcore
GGZ Gaming Zone

begin                                  rubytoe
  require "TTTAI"                      game server
  $ai = TTTAI.new
  puts "## Info: Using TTT-AI plugin ##"
rescue LoadError
  $ai = nil
  puts "## Warning: TTT-AI not found, using
internal random AI ##"
end
GGZ Gaming Zone
begin
  require "TTTAI"
  $ai = TTTAI.new
                                              rubytoe
  puts "## Info: Using TTT-AI plugin for higher game server
        def find_move(p)
intelligence $ai then
            if ##"
rescue LoadError
              return $ai.ai_findmove(p, 1, @board)
  $ai = nil end
  puts "## Warning: TTT-AI not found, using
            for i in 0..100
internal random AI rand(9)
              move = ##"
end     	

   if evaluate_move(p, move) == ::MOVE_OK then
                  return move
       	

       end
             e
       nd
           return -1
         end
       end
Is Ruby
a legitimate player
        in the
   gaming space?
Building Games with Ruby
               Resources
GGZ Gaming Zone    www.ggzgamingzone.org/
            Gosu     code.google.com/p/gosu/
 Nebular Gauntlet        nebulargauntlet.org/
         Ogre.rb       ogrerb.rubyforge.org/
          Railgun rubyforge.org/projects/railgun/
       Rubygame rubygame.sourceforge.net/
       RubySDL kmc.gr.jp/~ohai/rubysdl.en.html
           RUDL sourceforge.net/projects/rudl/
  Shattered Ruby groups.google.com/group/shatteredruby
                            wiki.shatteredruby.com

More Related Content

What's hot

The Ring programming language version 1.8 book - Part 53 of 202
The Ring programming language version 1.8 book - Part 53 of 202The Ring programming language version 1.8 book - Part 53 of 202
The Ring programming language version 1.8 book - Part 53 of 202Mahmoud Samir Fayed
 
Exploring Canvas
Exploring CanvasExploring Canvas
Exploring CanvasKevin Hoyt
 
PyCon2009_AI_Alt
PyCon2009_AI_AltPyCon2009_AI_Alt
PyCon2009_AI_AltHiroshi Ono
 
How to make a video game
How to make a video gameHow to make a video game
How to make a video gamedandylion13
 
The Ring programming language version 1.6 book - Part 50 of 189
The Ring programming language version 1.6 book - Part 50 of 189The Ring programming language version 1.6 book - Part 50 of 189
The Ring programming language version 1.6 book - Part 50 of 189Mahmoud Samir Fayed
 
Implementing a Simple Game using libGDX
Implementing a Simple Game using libGDXImplementing a Simple Game using libGDX
Implementing a Simple Game using libGDXJussi Pohjolainen
 
The Ring programming language version 1.8 book - Part 59 of 202
The Ring programming language version 1.8 book - Part 59 of 202The Ring programming language version 1.8 book - Part 59 of 202
The Ring programming language version 1.8 book - Part 59 of 202Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 70 of 210
The Ring programming language version 1.9 book - Part 70 of 210The Ring programming language version 1.9 book - Part 70 of 210
The Ring programming language version 1.9 book - Part 70 of 210Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 48 of 184
The Ring programming language version 1.5.3 book - Part 48 of 184The Ring programming language version 1.5.3 book - Part 48 of 184
The Ring programming language version 1.5.3 book - Part 48 of 184Mahmoud Samir Fayed
 
In a galaxy far, far away - A procedural generation tale
In a galaxy far, far away - A procedural generation taleIn a galaxy far, far away - A procedural generation tale
In a galaxy far, far away - A procedural generation taleShay Davidson
 
Stegosploit - Hack.LU 2015
Stegosploit - Hack.LU 2015Stegosploit - Hack.LU 2015
Stegosploit - Hack.LU 2015Saumil Shah
 
HoloLens Programming Tutorial: AirTap & Spatial Mapping
HoloLens Programming Tutorial: AirTap & Spatial MappingHoloLens Programming Tutorial: AirTap & Spatial Mapping
HoloLens Programming Tutorial: AirTap & Spatial MappingTakashi Yoshinaga
 

What's hot (19)

CreateJS
CreateJSCreateJS
CreateJS
 
The Ring programming language version 1.8 book - Part 53 of 202
The Ring programming language version 1.8 book - Part 53 of 202The Ring programming language version 1.8 book - Part 53 of 202
The Ring programming language version 1.8 book - Part 53 of 202
 
libGDX: Tiled Maps
libGDX: Tiled MapslibGDX: Tiled Maps
libGDX: Tiled Maps
 
Exploring Canvas
Exploring CanvasExploring Canvas
Exploring Canvas
 
PyCon2009_AI_Alt
PyCon2009_AI_AltPyCon2009_AI_Alt
PyCon2009_AI_Alt
 
Box2D and libGDX
Box2D and libGDXBox2D and libGDX
Box2D and libGDX
 
Code Pad
Code PadCode Pad
Code Pad
 
How to make a video game
How to make a video gameHow to make a video game
How to make a video game
 
The Ring programming language version 1.6 book - Part 50 of 189
The Ring programming language version 1.6 book - Part 50 of 189The Ring programming language version 1.6 book - Part 50 of 189
The Ring programming language version 1.6 book - Part 50 of 189
 
Implementing a Simple Game using libGDX
Implementing a Simple Game using libGDXImplementing a Simple Game using libGDX
Implementing a Simple Game using libGDX
 
The Ring programming language version 1.8 book - Part 59 of 202
The Ring programming language version 1.8 book - Part 59 of 202The Ring programming language version 1.8 book - Part 59 of 202
The Ring programming language version 1.8 book - Part 59 of 202
 
Real life XNA
Real life XNAReal life XNA
Real life XNA
 
The Ring programming language version 1.9 book - Part 70 of 210
The Ring programming language version 1.9 book - Part 70 of 210The Ring programming language version 1.9 book - Part 70 of 210
The Ring programming language version 1.9 book - Part 70 of 210
 
Cocos2dx 7.1-7.2
Cocos2dx 7.1-7.2Cocos2dx 7.1-7.2
Cocos2dx 7.1-7.2
 
The Ring programming language version 1.5.3 book - Part 48 of 184
The Ring programming language version 1.5.3 book - Part 48 of 184The Ring programming language version 1.5.3 book - Part 48 of 184
The Ring programming language version 1.5.3 book - Part 48 of 184
 
In a galaxy far, far away - A procedural generation tale
In a galaxy far, far away - A procedural generation taleIn a galaxy far, far away - A procedural generation tale
In a galaxy far, far away - A procedural generation tale
 
Stegosploit - Hack.LU 2015
Stegosploit - Hack.LU 2015Stegosploit - Hack.LU 2015
Stegosploit - Hack.LU 2015
 
HoloLens Programming Tutorial: AirTap & Spatial Mapping
HoloLens Programming Tutorial: AirTap & Spatial MappingHoloLens Programming Tutorial: AirTap & Spatial Mapping
HoloLens Programming Tutorial: AirTap & Spatial Mapping
 
662305 LAB12
662305 LAB12662305 LAB12
662305 LAB12
 

Similar to building_games_with_ruby_rubyconf

The Ring programming language version 1.5.2 book - Part 47 of 181
The Ring programming language version 1.5.2 book - Part 47 of 181The Ring programming language version 1.5.2 book - Part 47 of 181
The Ring programming language version 1.5.2 book - Part 47 of 181Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 46 of 180
The Ring programming language version 1.5.1 book - Part 46 of 180The Ring programming language version 1.5.1 book - Part 46 of 180
The Ring programming language version 1.5.1 book - Part 46 of 180Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 48 of 185
The Ring programming language version 1.5.4 book - Part 48 of 185The Ring programming language version 1.5.4 book - Part 48 of 185
The Ring programming language version 1.5.4 book - Part 48 of 185Mahmoud Samir Fayed
 
Following are the changes mentioned in bold in order to obtain the r.pdf
Following are the changes mentioned in bold in order to obtain the r.pdfFollowing are the changes mentioned in bold in order to obtain the r.pdf
Following are the changes mentioned in bold in order to obtain the r.pdfanithareadymade
 
Game development with Cocos2d
Game development with Cocos2dGame development with Cocos2d
Game development with Cocos2dVinsol
 
Introduction to Coding
Introduction to CodingIntroduction to Coding
Introduction to CodingFabio506452
 
Leaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGLLeaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGLgerbille
 
C++ game development with oxygine
C++ game development with oxygineC++ game development with oxygine
C++ game development with oxyginecorehard_by
 
The Ring programming language version 1.7 book - Part 63 of 196
The Ring programming language version 1.7 book - Part 63 of 196The Ring programming language version 1.7 book - Part 63 of 196
The Ring programming language version 1.7 book - Part 63 of 196Mahmoud Samir Fayed
 
Trident International Graphics Workshop 2014 1/5
Trident International Graphics Workshop 2014 1/5Trident International Graphics Workshop 2014 1/5
Trident International Graphics Workshop 2014 1/5Takao Wada
 
Intro to computer vision in .net
Intro to computer vision in .netIntro to computer vision in .net
Intro to computer vision in .netStephen Lorello
 
用 OPENRNDR 將 Chatbot 訊息視覺化
用 OPENRNDR 將 Chatbot 訊息視覺化用 OPENRNDR 將 Chatbot 訊息視覺化
用 OPENRNDR 將 Chatbot 訊息視覺化Shengyou Fan
 
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymoreHTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymoreRemy Sharp
 
The Ring programming language version 1.10 book - Part 58 of 212
The Ring programming language version 1.10 book - Part 58 of 212The Ring programming language version 1.10 book - Part 58 of 212
The Ring programming language version 1.10 book - Part 58 of 212Mahmoud Samir Fayed
 
Webgl para JavaScripters
Webgl para JavaScriptersWebgl para JavaScripters
Webgl para JavaScriptersgerbille
 
Lab Practices and Works Documentation / Report on Computer Graphics
Lab Practices and Works Documentation / Report on Computer GraphicsLab Practices and Works Documentation / Report on Computer Graphics
Lab Practices and Works Documentation / Report on Computer GraphicsRup Chowdhury
 
Advanced Game Development with the Mobile 3D Graphics API
Advanced Game Development with the Mobile 3D Graphics APIAdvanced Game Development with the Mobile 3D Graphics API
Advanced Game Development with the Mobile 3D Graphics APITomi Aarnio
 
Can someone please explain what the code below is doing and comment on.pdf
Can someone please explain what the code below is doing and comment on.pdfCan someone please explain what the code below is doing and comment on.pdf
Can someone please explain what the code below is doing and comment on.pdfkuldeepkumarapgsi
 
Strategies for refactoring and migrating a big old project to be multilingual...
Strategies for refactoring and migrating a big old project to be multilingual...Strategies for refactoring and migrating a big old project to be multilingual...
Strategies for refactoring and migrating a big old project to be multilingual...benjaoming
 

Similar to building_games_with_ruby_rubyconf (20)

The Ring programming language version 1.5.2 book - Part 47 of 181
The Ring programming language version 1.5.2 book - Part 47 of 181The Ring programming language version 1.5.2 book - Part 47 of 181
The Ring programming language version 1.5.2 book - Part 47 of 181
 
The Ring programming language version 1.5.1 book - Part 46 of 180
The Ring programming language version 1.5.1 book - Part 46 of 180The Ring programming language version 1.5.1 book - Part 46 of 180
The Ring programming language version 1.5.1 book - Part 46 of 180
 
The Ring programming language version 1.5.4 book - Part 48 of 185
The Ring programming language version 1.5.4 book - Part 48 of 185The Ring programming language version 1.5.4 book - Part 48 of 185
The Ring programming language version 1.5.4 book - Part 48 of 185
 
Following are the changes mentioned in bold in order to obtain the r.pdf
Following are the changes mentioned in bold in order to obtain the r.pdfFollowing are the changes mentioned in bold in order to obtain the r.pdf
Following are the changes mentioned in bold in order to obtain the r.pdf
 
Game development with Cocos2d
Game development with Cocos2dGame development with Cocos2d
Game development with Cocos2d
 
Introduction to Coding
Introduction to CodingIntroduction to Coding
Introduction to Coding
 
Leaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGLLeaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGL
 
C++ game development with oxygine
C++ game development with oxygineC++ game development with oxygine
C++ game development with oxygine
 
The Ring programming language version 1.7 book - Part 63 of 196
The Ring programming language version 1.7 book - Part 63 of 196The Ring programming language version 1.7 book - Part 63 of 196
The Ring programming language version 1.7 book - Part 63 of 196
 
Trident International Graphics Workshop 2014 1/5
Trident International Graphics Workshop 2014 1/5Trident International Graphics Workshop 2014 1/5
Trident International Graphics Workshop 2014 1/5
 
Intro to computer vision in .net
Intro to computer vision in .netIntro to computer vision in .net
Intro to computer vision in .net
 
用 OPENRNDR 將 Chatbot 訊息視覺化
用 OPENRNDR 將 Chatbot 訊息視覺化用 OPENRNDR 將 Chatbot 訊息視覺化
用 OPENRNDR 將 Chatbot 訊息視覺化
 
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymoreHTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymore
 
The Ring programming language version 1.10 book - Part 58 of 212
The Ring programming language version 1.10 book - Part 58 of 212The Ring programming language version 1.10 book - Part 58 of 212
The Ring programming language version 1.10 book - Part 58 of 212
 
Webgl para JavaScripters
Webgl para JavaScriptersWebgl para JavaScripters
Webgl para JavaScripters
 
Videogiochi in PHP 👾
Videogiochi in PHP 👾Videogiochi in PHP 👾
Videogiochi in PHP 👾
 
Lab Practices and Works Documentation / Report on Computer Graphics
Lab Practices and Works Documentation / Report on Computer GraphicsLab Practices and Works Documentation / Report on Computer Graphics
Lab Practices and Works Documentation / Report on Computer Graphics
 
Advanced Game Development with the Mobile 3D Graphics API
Advanced Game Development with the Mobile 3D Graphics APIAdvanced Game Development with the Mobile 3D Graphics API
Advanced Game Development with the Mobile 3D Graphics API
 
Can someone please explain what the code below is doing and comment on.pdf
Can someone please explain what the code below is doing and comment on.pdfCan someone please explain what the code below is doing and comment on.pdf
Can someone please explain what the code below is doing and comment on.pdf
 
Strategies for refactoring and migrating a big old project to be multilingual...
Strategies for refactoring and migrating a big old project to be multilingual...Strategies for refactoring and migrating a big old project to be multilingual...
Strategies for refactoring and migrating a big old project to be multilingual...
 

More from tutorialsruby

&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
 
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>tutorialsruby
 
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>tutorialsruby
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
 
Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0tutorialsruby
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269tutorialsruby
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269tutorialsruby
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008tutorialsruby
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008tutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheetstutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheetstutorialsruby
 

More from tutorialsruby (20)

&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
 
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0
 
xhtml_basics
xhtml_basicsxhtml_basics
xhtml_basics
 
xhtml_basics
xhtml_basicsxhtml_basics
xhtml_basics
 
xhtml-documentation
xhtml-documentationxhtml-documentation
xhtml-documentation
 
xhtml-documentation
xhtml-documentationxhtml-documentation
xhtml-documentation
 
CSS
CSSCSS
CSS
 
CSS
CSSCSS
CSS
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
 

Recently uploaded

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
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
 
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
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
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
 
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
 
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
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
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
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 

Recently uploaded (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
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
 
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
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
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...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
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...
 
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 ...
 
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
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
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
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 

building_games_with_ruby_rubyconf

  • 1. High A! on top of Low-level APIs Building Games with Ruby Andrea O. K. Wright, Chariot Solutions www.chariotsolutions.com
  • 2. High A! on top of Low-level APIs Building Games with Ruby Agenda 1. Buiding 2D Games with Ruby 2. Building 3D Games with Ruby 3. Is Ruby a legitimate player in the gaming space?
  • 3. Creator and Lead Developer: Ohai http://www.kmc.gr.jp/~ohai/rubysdl.en.html
  • 5. C Extension Uint32 SDL_GetTicks(void); static VALUE sdl_getTicks(VALUE mod) { return UINT2NUM(SDL_GetTicks()); }
  • 6. C Extension Uint32 SDL_GetTicks(void); static VALUE sdl_getTicks(VALUE mod) { return UINT2NUM(SDL_GetTicks()); } rb_define_module_function(mSDL, "getTicks", sdl_getTicks,0);
  • 7. C Extension Uint32 SDL_GetTicks(void); static VALUE sdl_getTicks(VALUE mod) { return UINT2NUM(SDL_GetTicks()); } rb_define_module_function(mSDL, "getTicks", sdl_getTicks,0); alias get_ticks getTicks
  • 11. Introducing Sprites sprites = [] for i in 1..5 sprites << Sprite.new end sprites << MovableSp.new
  • 12. Sample Event Loop while true while event = SDL::Event2.poll case event when SDL::Event2::Quit exit when SDL::Event2::KeyDown exit if event.sym == SDL::Key::ESCAPE end end screen.fillRect(0,0,640,480,0) SDL::Key.scan sprites.each {|i| i.move i.draw(screen) } screen.updateRect(0,0,0,0) end
  • 13. Sprite: Random Motion class Sprite def initialize @x=rand(640) ... @dx=rand(11)-5 end def move @x += @dx if @x >= 640 then @dx *= -1 @x = 639 end if @x < 0 then @dx *= -1 @x = 0 end ... end def draw(screen) SDL.blitSurface($image,0,0,32,32,screen,@x,@y) end end
  • 14. Event-Driven Sprite class MovableSp def initialize() @ud=@lr=0; end def move() @ud=@lr=0; @lr=-1 if SDL::Key.press?(SDL::Key::LEFT) @lr=1 if SDL::Key.press?(SDL::Key::RIGHT) @ud=1 if SDL::Key.press?(SDL::Key::DOWN) @ud=-1 if SDL::Key.press?(SDL::Key::UP) end def draw(screen) SDL.blitSurface($image,0,0,32,32, screen,300+@lr*50,200+@ud*50) end end
  • 15. Steven Davidovitz’s Nebular Gauntlet Project Home: http://www.nebulargauntlet.org/
  • 16. Steven Davidovitz’s Nebular Gauntlet while !@@quit handle_input() # Handle keyboard input do_think() # Do calculations/thinking do_render() # Render everything Signal.trap("INT", @on_quit) Signal.trap("EXIT", @on_quit) end Project Home: http://www.nebulargauntlet.org/
  • 17. Steven Davidovitz’s Nebular Gauntlet class Radar < Box def initialize(screen, size_modifier, *objects) @size = size_modifier height = $map.h / @size width = $map.w / @size super(screen, height, width) @objects = objects end def draw @screen.drawRect(@x, @y, @width, @height, @bcol) @objects.each do |obj| @screen.drawFilledCircle(0 + (obj.x / @size, 0 + (obj.y / @size), 2, [200, 200, 200]) if obj.state == :alive end end end Project Home: http://www.nebulargauntlet.org/
  • 18. Danny Van Bruggen, Creator http://sourceforge.net/projects/rudl/
  • 19. Principle of Least Surprise? SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp,Uint32 flags); static VALUE displaySurface_new(int argc, VALUE* argv, VALUE self)
  • 20. Principle of Least Surprise? screen = SDL::setVideoMode(640,480,16,SDL::SWSURFACE) display = DisplaySurface.new([640,480])
  • 21. Principle of Least Surprise? static VALUE sdl_setVideoMode(VALUE mod,VALUE w,VALUE h, VALUE bpp,VALUE flags){ SDL_Surface *screen; screen = SDL_SetVideoMode(NUM2INT(w),NUM2INT(h, NUM2IN (bpp), NUM2UINT(flags)); if(screen == NULL){ rb_raise(eSDLError, "Couldn't set %dx%d %d bpp video mode:%s", NUM2INT(w),NUM2INT(h),NUM2INT(bpp),SDL_GetError()); } return Data_Wrap_Struct(cScreen,0,0,screen); } rb_define_module_function(mSDL, "setVideoMode", sdl_setVideoMode,4);
  • 22. Principle of Least Surprise? static VALUE displaySurface_new(int argc, VALUE* argv, VALUE self) { ... surf = SDL_SetVideoMode(w, h, depth, flags); currentDisplaySurface = Data_Wrap_Struct (classDisplaySurface, 0, 0, surf); return currentDisplaySurface; }) rb_define_singleton_method(classDisplaySurface, "new", displaySurface_new, -1);
  • 23. Principle of Least Surprise? screen = SDL::setVideoMode(640,480,16,SDL::SWSURFACE) display = DisplaySurface.new([640,480])
  • 24. OpenGL http://nehe.gamedev.net/ RUDL Ports of Neon Helium Tutorials, Packaged with RUDL, Ported by Martin Stannard
  • 25. OpenGL def init(w,h) GL.ClearColor(0.0, 0.0, 0.0, 0.0) GL.ClearDepth(1.0) GL.DepthFunc(GL::LESS) GL.Enable(GL::DEPTH_TEST) GL.ShadeModel(GL::SMOOTH) GL.MatrixMode(GL::PROJECTION) GL.LoadIdentity() GLU.Perspective(45.0, w.to_f/h.to_f, 0.1, 100.0) GL.MatrixMode(GL::MODELVIEW) GL.LoadIdentity() GLU.LookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0) end Source by Martin Stannard: from RUDL samples
  • 26. OpenGL display = Proc.new { GL.Clear(GL::COLOR_BUFFER_BIT| GL::DEPTH_BUFFER_BIT) GL.Color(1.0, 1.0, 1.0) GL.LoadIdentity() GL.Translate(-1.5, 0.0, -6.0) # draw a triangle GL.Begin(GL::POLYGON) GL.Color3f(1.0, 0.0, 0.0) GL.Vertex3f(0.0, 1.0, 0.0) GL.Color3f(0.0, 1.0, 0.0) GL.Vertex3f(1.0,-1.0, 0.0) GL.Color3f(0.0, 0.0, 1.0) GL.Vertex3f(-1.0,-1.0, 0.0) GL.End() GL.Translate(3.0,0.0,0.0) } Source by Martin Stannard: from RUDL samples
  • 27. Creator and Lead Developer: John Croisant http://rubygame.sourceforge.net/info.html
  • 31. and Rect left centerx right (x, y) midtop top topleft topright midleft midright centery center bottomleft bottomright bottom midbottom @rect.topleft = 10,10
  • 32. and Rect # Attempt to punch a target. # Returns true if it hit or false if not. def punch(target) @punching = true return @rect.inflate(-5,-5).collide_rect?(target.rect) end
  • 33. and Sprites::Sprite, Sprites::Groups, Sprites::UpdateGroups Sample Packaged with Rubygame
  • 34. Edge
  • 35. Edge Scene Management Sample Packaged with the Development 3.0.0 branch
  • 36. Edge and ruby = GLImageSprite.new { @surface = Surface.load_image('ruby.png') setup_texture() @pos = Vector2[100,300] @depth = -0.1 @angle = -0.2 }
  • 37. Edge
  • 38.
  • 39. Co-Creators: Julian Raschke & Jan Lücker Lead Developer: Julian Raschke http://code.google.com/p/gosu/
  • 41. Main Window class MainWindow < Gosu::Window def initialize(width, height, fullscreen) super end def update # Change display attributes, if necessary. def draw # Display calls go here. end def button_down(id) # Buttons are keys, mouse buttons, and # game pad controls. end end w = MyWindow.new(640, 480, false) w.show
  • 42. Techniques class Star attr_reader :x, :y def initialize(animation) @animation = animation @color = Gosu::Color.new(0xff000000) @color.red = rand(255 - 40) + 40 @color.green = rand(255 - 40) + 40 @color.blue = rand(255 - 40) + 40 @x = rand * 640 @y = rand * 480 end def draw img = @animation[Gosu::milliseconds/100 % @animation.size] img.draw(@x - img.width/2.0, @y - img.height/2.0, ZOrder::Stars, 1, 1, @color, :additive) end end
  • 43. Nightly Travels of a Witch Team Tortilla: Florian Gross, Julian Raschke, Alexander Post
  • 44. and wiki.slembcke.net/main/published/Chipmunk Creator and Developer: Scott Lembcke Sample Packaged with Chipmunk
  • 45. and if rand(100) < 4 and @stars.size < 25 then body = CP::Body.new(0.0001, 0.0001) shape = CP::Shape::Circle.new(body, 25/2, CP::Vec2.new(0.0, 0.0)) shape.collision_type = :star @space.add_body(body) @space.add_shape(shape) stars.push(Star.new(@star_anim, shape)) end GosuChipmunk Tutorial by Dirk Johnson
  • 46. and Based on a Tutorial By Dirk Johnson
  • 48. and def remove_dirt point, radius $playfield_buffer.filled_circle([point[0], point[1]], radius, [0,0,0]) $backbuffer.filled_circle([point[0],point[1]], radius, [0,0,0]) end Sample Packaged with RUDL “Barrage” by Brian Palmer, Pocket Martian Software
  • 49. and if not @crater_image then @crater_image = Magick::Image.new(50, 50) {self.background_color = 'none'} gc = Magick::Draw.new gc.fill('black').circle(25, 25, 25, 0) gc.draw(@crater_image) @crater_shadow = @crater_image.shadow(0,0,5,1) end @crater_image @crater_shadow
  • 50. and @rmagick_images[index].composite!(@crater_shadow, center_x - 35, center_y - 35, Magick::AtopCompositeOp) @rmagick_images[index].composite!(@crater_image, center_x - 25, center_y - 25, @crater_image @crater_shadow Magick::DstOutCompositeOp) @gosu_images[index] = Gosu::Image.new(@window, @rmagick_images[index], true)
  • 51. and def draw gl do glClearColor(0.0, 0.2, 0.5, 1.0) glClearDepth(0) glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) @gl_background.exec_gl end ... end
  • 53. and def exec_gl info = @image.gl_tex_info ... 0.upto(POINTS_Y - 2) do |y| 0.upto(POINTS_X - 2) do |x| glBegin(GL_TRIANGLE_STRIP) z = @height_map[y][x] glColor4d(1, 1, 1, z) glTexCoord2d(info.left, info.top) glVertex3d(-0.5 + (x - 0.0) / (POINTS_X-1), -0.5 + (y - offs_y - 0.0) / (POINTS_Y-2), z) ... glEnd end end end
  • 54. Creator and Lead Developer: Jason Roelofs http://ogrerb.rubyforge.org/index.html
  • 56. Shattered Ruby Co-Creators and Co-Lead Developers: Martyn Garcia and Mikkel Garcia http://groups.google.com/group/shatteredruby
  • 58. Shattered Ruby Martyn Garcia on Shattered Ruby vs. Rails “...while Rails has a simple text output view, Shattered has a very complex 3d rendering. And while Shattered has simple game logic, Rails has a very complex database backend. Our focus is swapped. The way Rails gains a ton of power is by making assumptions on the model. ..[o]ur view is the largest part...”
  • 59. ShatteredRuby From the Ogre.rb Samples class SkyPlaneApplication < Application def create_scene scene_manager.set_ambient_light ColourValue.new(0.5, 0.5, 0.5) plane = Plane.new plane.d = 5000 plane.normal = -Vector3.UNIT_Y scene_manager.set_sky_plane(true, plane,"SpaceSkyPlane", 10000, 3) light = scene_manager.create_light("MainLight") light.set_position(20, 80, 50) dragon = scene_manager.create_entity("dragon", "dragon.mesh") scene_manager.root_scene_node.attach_object(dragon) end end
  • 60. ShatteredRuby From the Ogre.rb Samples class SkyPlaneApplication < Application def create_scene scene_manager.set_ambient_light ColourValue.new(0.5, 0.5, 0.5) plane = Plane.new Shattering the Code.... plane.d = 5000 plane.normal = -Vector3.UNIT_Y scene_manager.set_sky_plane(true, plane,"SpaceSkyPlane", 10000, 3) class SkyPlane light = scene_manager.create_light("MainLight") light.set_position(20, 80, 50) light “Mainlight”, dragon = scene_manager.create_entity("dragon", :position => (20,80,50) "dragon.mesh") end scene_manager.root_scene_node.attach_object(dragon) end class Dragon end end
  • 61. Shattered Ruby Symbols to Vector :x.to_v #v(1,0,0) :y.to_v #v(0,1,0) :z.to_v #v(0,0,1) :up.to_v #v(0,1,0) :down.to_v #v(0,-1,0) :left.to_v #v(-1,0,0) :right.to_v #v(1,0,0) :forward.to_v #v(0,0,1) :backward.to_v #v(0,0,-1) :zero.to_v #v(0,0,0)
  • 62. Shattered Ruby Timers class Bomb < ... timer :in => 30.seconds, :action => :blow_up timer :every => 1.second, :action => :shorten_fuse def blow_up ... end def shorten_fuse ... end end from the Shattered Wiki: http://wiki.shatteredruby.com/index.php?title=Timers
  • 64. Shattered Ruby > shatter space_race create app/models create app/views create app/media/common/programs create app/media/common/templates create doc create config create log create script create test/unit create vendor create vendor/plugins create Rakefile create README create config/ogre_plugins.windows.cfg create config/ogre.cfg create config/boot.rb create config/environment.rb create test/test_helper.rb create script/generate create script/runner create script/console ...
  • 65. ShatteredRuby ModelViewActor Architecture Actor space_race>script/generate actor flying_carpet exists app/models/ exists test/unit/ Model create app/models/flying_carpet.rb create test/unit/flying_carpet_test.rb exists app/views/ create app/media/flying_carpet View create app/views/flying_carpet_view.rb create app/media/flying_carpet/flying_carpet.mesh create app/media/flying_carpet/flying_carpet.png Model Contains game logic and handles user input events. When a method is called on the Model, and a method with the same name exists on the View -- the View’s method is automatically invoked. View The View responds to methods on the Model.
  • 66. ShatteredRuby State Management space_race>script/generate state menu create app/states/ create app/states/menu_state.rb space_race>script/generate state game exists app/states/ create app/states/game_state.rb State Represents routes through the application Provides a top level where actors can interact
  • 67. ShatteredRuby OGRE Materials Format // This is a comment material walls/funkywall1 { // first, preferred technique technique { // first pass pass { ambient 0.5 0.5 0.5 diffuse 1.0 1.0 1.0 // Texture unit 0 texture_unit { texture wibbly.jpg scroll_anim 0.1 0.0 wave_xform scale sine 0.0 0.7 0.0 1.0 } // Texture unit 1 (this is a multitexture pass) texture_unit { texture wobbly.png rotate_anim 0.25 colour_op add } } } // Second technique, can be used as a fallback or LOD level technique { // .. and so on } } (from the OGRE manual: http://www.ogre3d.org/docs/manual/manual_14.html)
  • 68. Shattered Ruby Rmaterials material < %= name % > OGRE Materials Format { // This is a comment technique material walls/funkywall1 { { // first, preferred technique technique { // first pass pass pass { { ambient 0.5 0.5 0.5 diffuse 1.0 1.0 1.0 lighting off // Texture unit 0 texture_unit { texture_unit { texture wibbly.jpg scroll_anim 0.1 0.0 wave_xform scale sine 0.0 0.7 0.0 1.0 } texture < %= texture % > // Texture unit 1 (this is a multitexture pass) texture_unit { } } texture wobbly.png rotate_anim 0.25 colour_op add } } } } } // Second technique, can be used as a fallback or LOD level technique { // .. and so on } material :flying_carpet, :template => 'basic', } (from the OGRE manual: :texture => 'tapestry.png' http://www.ogre3d.org/docs/manual/manual_14.html)
  • 70. Shattered Ruby That’s right, there are no more “What, Shattered doesn’t support per vertex bi-quadruple render transmutation?! -- that’s outragous!”. Anything supported in Ogre will be supported in Shattered! -- Mikkel Garcia
  • 73. Shattered Ruby Co-Creators and Co-Lead Developers: Martyn Garcia and Mikkel Garcia http://groups.google.com/group/shatteredruby
  • 74. Creator and Lead Developers: David Koontz http://rubyforge.org/projects/railgun/
  • 75. High A! on top of Low-level APIs Building Games with Ruby Agenda 1. Buiding 2D Games with Ruby 2. Building 3D Games with Ruby 3. Is Ruby a legitimate player in the gaming space?
  • 76. The GGZ Gaming Zone Project Founders: Brent M. Hendricks and Rich Gade Developed & Maintained by an International Team http://www.ggzgamingzone.org/
  • 77. GGZ Gaming Zone http://games.ggzcommunity.org/ http://live.ggzgamingzone.org:5688/ localhost:5688/
  • 78. GGZ Gaming Zone GGZ GTK+ Core Client GGZ KDE Core Client
  • 80. GGZ Gaming Zone Iagno, GNOME Games
  • 81. GGZ Gaming Zone ggzcommgen game client net.c net.c game server Game Client/Game Server (tictactoe) Individual Protocol TCP/IP or UDP/IP ggzmod/game ggzdmod/server Game Client/Core Client Game Server/GGZ Server Binary Protocol Binary Protocol Local Connection Local Connection ggzmod/core ggzmod/core core client Core Client/GGZ Server ggz server XML Protocol TCP/IP ggzcore
  • 82. GGZ Gaming Zone game client Game Client to Core Client GAME_STATE(0), STAND(1), SIT(2), ggzmod/game BOOT(3), BOT(4), OPEN(5), CHAT(6) Core Client to Game Client ggzmod/core GAME_LAUNCH(0), GAME_SERVER(1), core client GAME_PLAYER (2), GAME_SEAT(3), core client GAME_SPECTATOR SEAT(4) GAME_CHAT(5), GAME_STATS(6)
  • 83. GGZ Gaming Zone game client Game Client to DATA TYPE Core Client Opcode 4 GAME_STATE(0), STAND(1), SIT(2), ggzmod/game BOOT(3), BOT(4), OPEN(5), Spectator Seat# CHAT(6) integer Spectator Name string Core Client to Game Client ggzmod/core GAME_LAUNCH(0), GAME_SERVER(1), core client GAME_PLAYER (2), GAME_SEAT(3), core client GAME_SPECTATOR SEAT(4) GAME_CHAT(5), GAME_STATS(6)
  • 84. GGZ Gaming Zone ggzcommgen game client net.c net.c game server Game Client/Game Server (tictactoe) Individual Protocol TCP/IP or UDP/IP ggzmod/game ggzdmod/server Game Client/Core Client Game Server/GGZ Server Binary Protocol Binary Protocol Local Connection Local Connection ggzmod/core ggzmod/core core client Core Client/GGZ Server ggz server XML Protocol TCP/IP ggzcore
  • 85. GGZ Gaming Zone ggzcommgen game client net.c net.c game server Game Client/Game Server (tictactoe) Individual Protocol TCP/IP or UDP/IP <ggzcomm engine="tictactoe" version="4"> <definitions> <def name="msggameover" value="3"/> </definitions> <server> ... <event name="msggameover"> <data name="winner" type="byte"/> </event> </server> </ggzcomm>
  • 86. GGZ Gaming Zone ggzcommgen game client net.c net.c game server Game Client/Game Server (tictactoe) Individual Protocol TCP/IP or UDP/IP <ggzcomm engine="tictactoe" version="4"> <definitions> void ggzcomm_msggameover(GGZCommIO * io) { <def name="msggameover" value="3"/> ret = ggz_write_int(io->fd, msggameover); </definitions> if(ret < 0) <server> ... ggzcomm_error(); ret = ggz_write_char(io >fd,variables.winner); <event name="msggameover"> if(ret < 0)name="winner" type="byte"/> <data ggzcomm_error(); </event> } </server> </ggzcomm>
  • 87. GGZ Gaming Zone ggzcommgen net.rb net.rb Ruby Game Client/Game Server Ruby game client Individual Protocol game server TCP/IP or UDP/IP <ggzcomm engine="tictactoe" version="4"> <definitions> <def name="msggameover" value="3"/> def send_gameover(p, winner) ... </definitions> s = <server> GGZRawSocket.for_fd($server.get_seat_fd(p)) ... <event name="msggameover"> s.puti(::MSG_GAMEOVER) s.putb(winner) name="winner" type="byte"/> <data end </event> </server> </ggzcomm>
  • 88. GGZ Gaming Zone ggzcommgen net.rb net.rb Ruby Ruby game client Game Client/Game Server game server Individual Protocol TCP/IP or UDP/IP ggzmod/game ruggzmod/ ruggzdmod ggzdmod/server RGGZMod Game Client/Core Client Game Server/GGZ Server Binary Protocol Binary Protocol Local Connection Local Connection ggzmod/core ggzmod/core core client Core Client/GGZ Server ggz server XML Protocol TCP/IP ggzcore
  • 89. GGZ Gaming Zone ggzcommgen net.rb net.rb QtRuby Game Client/Game Server Individual Protocol rubytoe game server game client TCP/IP or UDP/IP ggzmod/game ruggzmod/ ruggzdmod ggzdmod/server RGGZMod Game Client/Core Client Game Server/GGZ Server Binary Protocol Binary Protocol Local Connection Local Connection ggzmod/core ggzmod/core core client Core Client/GGZ Server ggz server XML Protocol TCP/IP ggzcore
  • 90. GGZ Gaming Zone ggzcommgen net.rb net.rb QtRuby Game Client/Game Server Individual Protocol rubytoe game server game client TCP/IP or UDP/IP ggzmod/game ruggzmod/ ruggzdmod ggzdmod/server RGGZMod Game Client/Core Client Game Server/GGZ Server Binary Protocol Binary Protocol Local Connection Local Connection ggzmod/core ggzmod/core core client Core Client/GGZ Server ggz server XML Protocol TCP/IP ggzcore
  • 91. GGZ Gaming Zone begin rubytoe require "TTTAI" game server $ai = TTTAI.new puts "## Info: Using TTT-AI plugin ##" rescue LoadError $ai = nil puts "## Warning: TTT-AI not found, using internal random AI ##" end
  • 92. GGZ Gaming Zone begin require "TTTAI" $ai = TTTAI.new rubytoe puts "## Info: Using TTT-AI plugin for higher game server def find_move(p) intelligence $ai then if ##" rescue LoadError return $ai.ai_findmove(p, 1, @board) $ai = nil end puts "## Warning: TTT-AI not found, using for i in 0..100 internal random AI rand(9) move = ##" end if evaluate_move(p, move) == ::MOVE_OK then return move end e nd return -1 end end
  • 93. Is Ruby a legitimate player in the gaming space?
  • 94. Building Games with Ruby Resources GGZ Gaming Zone www.ggzgamingzone.org/ Gosu code.google.com/p/gosu/ Nebular Gauntlet nebulargauntlet.org/ Ogre.rb ogrerb.rubyforge.org/ Railgun rubyforge.org/projects/railgun/ Rubygame rubygame.sourceforge.net/ RubySDL kmc.gr.jp/~ohai/rubysdl.en.html RUDL sourceforge.net/projects/rudl/ Shattered Ruby groups.google.com/group/shatteredruby wiki.shatteredruby.com