Hello Everybody, and Welcome to the first episode of Making Games With Ruby! I’m Tyler, and this video is brought to you by manwithcode.com
In this episode I’ll be covering what you will be learning in this series, what we’re using to develop our games, what I’m assuming about you, and why I’m teaching you.
What you’ll learn
If you couldn’t tell by the title, you’re going to learn how to make games using the Ruby programming language. More specifically I’m going to teach you how to make Pong. Though Pong may sound a little simplistic, and I’m not claiming it isn’t, learning how to make Pong will teach you almost everything you’ll need to know to make any game, with out getting bogged down in game specific details.
What we’re using
Of course we’re using the Ruby programming language. To create games, we’ll have the help of the Rubygame library, which is many things including a wrapper around SDL, and a nice framework for developing games.
In the creation of this series I will be using Ruby 1.8.7-p174, and Rubygame 2.6.2. Theoretically The code in this series should run on Ruby 1.8.whatever and Rubygame 2.whatever, no promises though, since languages and libraries change.
And if you want to know about my environment, I’ll be running Ubuntu 9.10 as my Operating System, and using Gedit as my text editor. You can write and run the code on any platform you wish, but this is what I prefer.
What I’m assuming about you
So I don’t have to explain every line of code to you, I’m going to be assuming that you already know the Ruby programming language. If you don’t there are many books available, as well as my own video series Programming With Ruby at http://manwithcode.com/ruby-programming-tutorials/
Just reading one book, or watching my video series probably isn’t enough. I’ll be easier if you have used Ruby for a while, and are comfortable with it. This isn’t
a requirement, but it would help make things easier on yourself.
Why I’m teaching this
There are many reasons why, but I’ll talk about the most important few:
1) I love making games.
2) I love teaching.
3) Teaching teaches me something. – When you actually sit down and think about what you do, things become more concrete, and you know why you do what you do, or even see bad habits that you need to correct
4) I’m trying to make money – Yep, I’m not going to try and hide this. Some of the videos in this series will be put up for sale, you’ll be able to see them as I put out more videos.
Thank you very much for watching! I’ll see you in the next video.
You can vote on what the next video series will be.
So if you vote I will know what YOU want, now you need to know what I
want for the next series to happen.
I’ve had well over 1,000 unique viewers of this video series, so I
need you viewers to donate a total of $1000 before I make the next
series. This may seem like a high amount, but if only 200 people
donate $5, that is a thousand dollars.
Now, what if you don’t have the money to donate? I will be making a
post on manwithcode.com named Ruby Video Tutorial Feedback, if 1000
people leave feedback (i.e. What they liked, what they didn’t like).
So whatever comes first, 1000 comments or $1000 will cause me to start
the next video series.
For updates on how close we are to each goal, I will be on twitter at
the account tylerjchurch and with the tag #manwithcode.
Hello Everybody and welcome to Programming With Ruby Episode 18, Out
Into The World. I’m Tyler and this video is brought to you by
In this episode I will be telling you where to go from here, now that
you know the basics of Ruby. I’ll show you some books, some common
libraries. And I’ll go over a few more things.
Where to go from here
Now that this series is almost done, you may be wondering what you
should do. First, I recommend you start writing your own
programs. Find something you would like to write and just try writing
You may also want to read a few other resources like books and online
tutorials about Ruby for things I didn’t cover and to reinforce what
you have learned.
For books I would recommend:
Beginning Ruby, From Novice to Professional
The Ruby Programming Language
If you are trying to make something, but can’t do it with Ruby alone,
here are some libraries in a few common areas. I won’t be providing
links, but a quick Google search will find them for you.
Ruby on Rails
If you need a library for something I didn’t cover, you can check
Ruby’s documentation at ruby-doc.org, you can try and find a project
by searching at rubyforge.org and github.com. If all else fails, just
This is actually the end of the episode, but though this video is
purported as the end of the series, there is going to be at least one
more video, so stay tuned.
If you’ve liked this series, please donate!
If you have and questions, comments, or suggestions about this series
or Man With Code, you can leave a comment on this page or email me at
Hello Everybody and welcome to Programming With Ruby Episode 17,
Getting Advanced. I’m Tyler, and this video is brought to you by
By now, you know a large amount about Ruby, so in this episode we will
be going over some advanced features that Ruby has.
More specifically I will be teaching you what Symbols are, and when to
use them. I will be showing you how to use eval, and how to use
bindings with eval. You will learn how to run other programs from
Ruby. Finally I will show you what safe levels are.
Lets get started!
Symbols are a type of variable that are very much like strings, but
more lightweight. Symbols look like this:
Symbols can’t be manipulated like strings can, which seems like a huge
drawback, but they do have a couple benefits.
Each time you use a string, to say access a hash. Ruby creates an
instance of that string. Where if you use a symbol, it is only ever
instanced once. Meaning that the use of symbols will take up less
memory than strings will, if you are, say accessing a hash many times.
Symbols are also slightly easier to type since the colon is on the
home row on US keyboards.
eval is a way of running Ruby code that is contained in a string. For
example, lets say you have a string that looks like this:
"puts 'Hello World'"
It is just a simple string, so it does nothing. But, if you use the
method eval on that string it will execute the code inside. So this
will print Hello World! on to the screen:
eval "puts 'Hello World!'"
This isn’t always useful, but you can use it if you want your users to
be able to enter Ruby code into your program.
You can also pass bindings to eval. So if we had this method
def my_method my_binding
eval "puts x", my_binding
x = 5
Some of you may notice that the variable x isn’t defined in the method my_method. By using the binding method, we can make variable scopes portable!
Running Other Programs
There comes a time when you will want to be able to run a program from
Ruby, maybe you want to automate something, or simply get the output
from an external program.
There are a few ways of doing this.
The first is with the method exec, which runs an external programs,
and quits the Ruby script at the same time:
exec('ls') # dir on windows
# Program never gets here
There is also system, which does the same thing, but doesn’t quit the
Ruby script, and returns true or false if the program was successful:
system('ls') # dir on windows
# we do get this far
Finally we have the “back-tick” `. Which looks like a sideways single
quote. On my keyboard it is above the tab key. You surround your
command in the back-ticks, like you would for a sting. Unlike the other
two methods of running a program, this method also returns the output
of the program you run.
variable = `ls`
If you are running a Ruby interpreter online or in another environment
where users can enter in and run Ruby code. They hold the ability to
wreak havoc on your system.
The way to prevent this from happening is by using safe levels. Safe
levels are a way of preventing the user from getting access to the
file system, or changing any variables that the program has.
You set safe levels by setting the $SAFE variable. By default it is
set to zero.
$SAFE = 4
Ruby “taints” objects that could be dangerous.
There are five different safe levels.
0 => The default, you can do anything
1 => Can’t use environment variable, eval, load, require, and more.
2 => Same as above and also can’t use files
3 => All objects created are tainted, can’t be untainted
4 => You can do almost nothing… Can’t modify the untainted, can’t
use exit. Basically completely safe and sand-boxed.
That brings us to the end of the episode. If you liked these videos,
please donate. It costs me in both money and time to make them.
If you have any questions, comments, or suggestions please don’t
hesitate to leave a comment on this page or email me at