Warning: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in ..../includes/class_bbcode.php on line 2958
Makeing games with sdl and ruby
Results 1 to 2 of 2

Thread: Makeing games with sdl and ruby

  1. #1
    Senior Member comtux's Avatar
    Join Date
    Sep 2004
    Wilkes Barre Pa

    Makeing games with sdl and ruby

    I discoverd a ruby lib call rudl .
    You want to talk about makeing games easy to build http://rudl.sourceforge.net/

    One of the demos i found interasting is this

    when you run the bobs.rb demo you get that and them balls swirls around the screen as more balls are added looks killer and makes for a great screen saver.

    @file Samples
    @class Bobs
    (adapted from a Pygame demo example thing)
    unlimited 'bobs' - korruptor
    I first saw this in the Dragons MegaDemo on the A500 back in '89 and it blew me away.
    How gutted I was when Wayne "tripix" Keenan told me how easy it was and knocked up an
    an example demo a couple of years later.
    For those of you that didn't know how it was done, here's a pygame example. It's
    basically a flick-book effect; you draw the same sprite in different positions on
    25 different 'screens' and flick between them. When you've drawn on all 25 you loop
    back to the beginning and keep on blitting.
    Sprite offsets make it look like you're adding sprites. Simple.
    require 'RUDL'
    include RUDL
    include Constant
    include Math
    # ------------------------------------------------------------------------------------
    RES = [640,480]
    PI = 3.14159
    DEG2RAD = PI/180
    # ------------------------------------------------------------------------------------
    def main
        surfaces= []
        # Initialise pygame, and grab an 8bit display.
        #screen= DisplaySurface.new RES,FULLSCREEN, 8
        screen= DisplaySurface.new [640,480] 
        bob= Surface.load_new 'media/bob.gif'
        # load a sprite and set the palette
        bob.set_colorkey [255,255,255]
        screen.set_palette 0, bob.palette
        # Create 25 blank surfaces to draw on.
        (0..25).each do |i|
            surfaces[i].set_palette 0, bob.palette
        xang = 0.0
        yang = 0.0
        surf = 0
        # Fruity loops...
        while true
            # Have we received an event to quit the program?
            EventQueue.get.each do |event|
                if [QuitEvent, KeyDownEvent, MouseButtonDownEvent].include? event.class
            # Get some x/y positions
            x = (RES[0]/2)*sin((xang*DEG2RAD)*0.75)
            y = (RES[1]/2)*cos((yang*DEG2RAD)*0.67)
            # Inc the angle of the sine
            xang += 1.17
            yang += 1.39
            # blit our 'bob' on the 'active' surface
            # blit the active surface to the screen
            # display the results
            # inc the active surface number
            surf = (surf+1) % 25
    # ------------------------------------------------------------------------------------
    # End of sauce. Pass the chips...
    This is the code looks fairly simple i had no problem editing it.
    That code is 89 lines and even with no gfx card just on board vide its fast.
    Wenn Sie Spaß meines Englisch mich Willensfuckingtötung Sie bilden.

  2. #2
    Oh, nice. I'm in the process of learning ruby, and seeing working examples of stuff like that keeps me going. Nice to know about SDL and ruby being able to work together, too.

Similar Threads

  1. Ruby / Ruby on Rails
    By coltrane in forum Linux - Software, Applications & Programming
    Replies: 3
    Last Post: 06-16-2006, 03:38 PM
  2. Makeing 1 server show the syslogs for 3 servers
    By Tarzan34 in forum Linux - General Topics
    Replies: 4
    Last Post: 02-18-2005, 08:28 PM
  3. makeing a distro
    By TeRG in forum Linux - General Topics
    Replies: 28
    Last Post: 02-11-2002, 10:59 AM
  4. My first Ruby script!
    By vee-eye in forum Programming
    Replies: 11
    Last Post: 01-14-2002, 09:49 AM
  5. Ruby
    By Ashcrow in forum Linux - Software, Applications & Programming
    Replies: 4
    Last Post: 12-01-2001, 11:35 PM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts