Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Beoran
Pages: 1 ... 7 8 [9] 10 11

81
Gaminjustin, I agree with your saying. Thanks for the tip on cave story, I must say it is *very nice*, and it even has a Linux version. This game also uses SDL. 

Atna, if you can't get Rubygame installed, perhaps you could try Ruby SDL in stead ? It's slightly more difficult to use, but the available functionality is even better than that of Rubygame. I'm in the process of switching to rubysdl myself, because I need those extras that Rubygame doesn't have yet. You can read more about how to install it here:

http://www.kmc.gr.jp/~ohai/rubysdl_download.en.html

Look for ruby/SDL version 2.0.1

You may need to install a different ruby or this though, the mswin32 ruby.
I'm sorry I can't be more helpful with a windows install, I use Linux at home.

82
Ok, I'm more than willing to carry on my tutorial, however, from what point should I continue? If you guys are interested, were you able to install Ruby and get started with using it? Should I start again, explaining Ruby from the very start, or just continue from where I got with Dragonboy, at the module level?

83
General Discussion / Re: top-down pixel art
« on: August 20, 2008, 09:56:29 pm »
Ptoing, I think most classic gamers would say that Zelda and the like are in "three quarter view", that is, not seen straight from the top down, but from an angle of about 3/4 of a straight angle  (67.5°) away from the ground. The fact that the head looks bigger than the body could be explained by the depth-perspective effect (although it's technically drawn incorrectly in most of those games, as you remarked.)

84
Yes, that's basically the way to do it. The point is that with things like Pygame or Rubygame you get the low level stuff basically pre-programed for you "for free", and then you can concentrate on the high level logic in the "scripting" language (Python or Ruby, respecively), as most of the hard work has already been done for you.

Dragonboy, if you're still up to it, I can continue my tutorial :)

85
Dragonboy are you still with us? Is anyone else interested in me continuing my tutorials this thread?  If neither is the case, then I'll let this thread rest for now.

86
Ah, I see. I think you installed Ruby correctly, but didn't  know how to get started with it.

Yes, to start programing, you need SciTE, that "notepad-like" program! Programming is done by writing texts in a sort of "better" notepad, and then letting the programming language run (= execute, do what you tell to do in your program) them.  Go back and read the message above, from Saturday 2 august at 07:56:21 AM about how to use SciTE for programing in Ruby.

In short, try to write things like

puts 123

in that "notepad thing", SciTE, save the file as program1.rb, and then you can run the program you just wrote and saved by pressing F5, or going in the menu and doing Tools->Go. Something (unimpressing) should happen, and the 123 will appear in a sepaate window. That is the output of your program. Please tell me if you have any problems getting this far.

87
Dragonboy, normally, installing  Ruby and Rubygames does not slows your computer down. Software that isn't used does nothing. I installed Ruby using the one click installer on one of my company' s PC and it's easy and fast. Probably there is something you didn't quite understand. Which is not a problem, I'll try to make it more clear to you. :)

First of all, to install ruby, look at the instructions here:
http://ruby.about.com/od/tutorials/ht/installrubywin.htm

You simply ave to download the ruby ine click installer from the link I ssent you before, and then double click on it, then the installer should appear on the screen, and you'll just have to click next, next, etc. After you installed Ruby, were you able to find SciTE in the start menu? You may need to look a bit around in the menu or scroll it a bit.

If you want to get some live help with installing Rubygame, you can try to connect to IRC using http://www.mibbit.com/
Choose Freenode.net from the drop down menu, fill in Dragonboy as your nickname, and #rubygame in the chanel box.
To ask questions about installing ruby, you could do the same but fill in #ruby as the channel name. 
IRC is a kind of chat that is very popular with computer programers, so I reccomend you use it. I'll be hanging around
a bit on both #ruby and #rubygame channels the next few days, so you can also ask me there. But I'm in Europe, so keep in mind the time difference.

I have some questions for you as well:

Do you have a basic understanding of how to work with your operating system (windows?), how to work with files, copy them, and uncompress zip files, and how to install applications? If you're unsure about all these things, please ask me, or please read the online help of your OS, or borrow a book about your OS in the library, or look at one of the many tutorials like this one: http://www.helpwithpcs.com/courses/windows-xp-tutorial-desktop.htm

Do you understand what I'm writing or is my English too bad or too difficult for you? I'm not a native English speaker, so perhaps I used some words that are wrong? Don't be afraid to ask! What are you using, Windows XP, or Windows Vista? Were you able to install the Ruby one click installer? Did you understand the instructions on how to install Ruby and Rubygames?

Anyway, he most important thing is to hang in there! :) You will have to learn if you want to program games, and it will take some time,
but I can assure you it's all worth it. I'm sure you can do it as long as you keep it up. :)

88
Pipebros:
Just a few nitpicks here, and I don't want to sound to harsh, so please don't take offense, ok? :)

The "level" of a language is how much work it takes out of your hands and does for you. C is not a high level language. It is a low-level language, since it almost does nothing for you implicitly. C++ is the a low level language C with a lot of high level stuff bolted on in a rather tricky way.  Of the currently top 10 popular languages (Google TIOBE Index), only Python or Ruby are truly high level and feature-complete languages. All other popular languages are either low level (C),  middle-level(Java,C#, Javascript) or miss some useful features (PHP, Basic) or are quite tricky to program in (C++, Perl).

IMO, C or C++ are only about 2 times faster to program in than assembler. Ruby and Python are easily 10 times faster to develop in than in assembler. That's why I went ahead with my series above as intro to game programing in Ruby for Dragonboy and other interested people here. Ruby or Python really are the fastest ways to get started with game programing and get something done, barring things like Gamemaker or RPG Maker (which also uses Ruby, in it's latest version, by the way). Dragonboy was already and understandably losing his patience with assembler, and thats why I chose to recommend him to start with Ruby (or Python) in stead. Although it cannot completely remove the learning curve, it will lead to encouraging results that much quicker, at least, I hope. :)

89
Next installment: a bit about loading libraries, modules, sub-modules and constants.

Ok, so you're probably roaring to go, and actualy do something that is actually related to game programing. Well, we're almost ready to start... but first, I have walk a last side-road for a while, sorry for that. :)

As you may have realised from looking at what puts 3.methods wrote on the screen, there is a huge amount of commands available to Ruby. So much, in fact, that probably no one would need all of them, and that the name of the command would have to become very long and perhaps confusing if all those commands were available directly.  To prevent this mess, related commands (procedures, functions) are grouped together into neat packages called "modules" in programmer lingo.

A good example of modules is the Math module. It contains more advances math commands, like trigonometry, or  the square root which is abbreviated to sqrt like this:
puts Math.sqrt(4)
-> will write 2.0 to the output.

"Math" is a module, an it contains several math related commands, like Math.cos Math.sin Math.tan Math.sqrt . So, what Math.now means to Ruby is, look into the Math module, for the sqrt command, and do what it must do. It's actually quite similar to
s = "Bob"
puts s.length
Where you put the text bob into s ,and then tell ruby that it has to look up the command/method length into the commands that are related to text strings, and hen do what it has to do for that string.

OK, but what if you get tired of always writing the name of the module in front of the command? Well, then you can do it like this:
include Math
puts sqrt(2)
the include command will take all commands that are in the Math module, and mke them direcly available, so you don't need to type the name of the module anymore.

Now, a bit about constants.
What's a constant? Well, it's much like a variable, that is , a named location where a value has been stored. However, different from a variable, you don' t want it to change. An example might be the value of PI, you know from the formula of the circle circumference is 2 times the radius of the circle times pi. Well, in Ruby, this value is in the Math module. Try this:
puts Math::PI
-> 3.14159265358979

The value of PI is something that's not supposed to change, so, that's why it's a constant. You use the :: in stead of a . to look up the value of PI in the math module, because PI is not a command, just a constant, and it would confuse Ruby if you mixed up the two of them. How does Ruby know that PI is supposed to be a constant and not a variable? Well, simple, it looks at the first letter, and if that's a capital letter, it treats the thing thus named like a constant.

Did you notice the name of the Math module is also a capital letter? Yes, it's a constant , because, you probably don't want to change the contents of that module (the functions that it contains).

One other problem with the huge amount of commands potentially available to Ruby  is speed. The more commands that Ruby has to know about, the more time it has to spend looking them up, slowing down things. Just like a clerk in a big book shop will need more time to find a book than one working in a tiny book shop. So, that's why all of these commands have been split up into different parts, called "libraries". Almost all programing languages do split up their functionality over libraries, so you can make the program run on a "need to know" basis, which is good for speed and simplicity. Libraries also allow many different people to work on ading new commands to a programmin glanguage.

A good example of a library is of course the rubygame library, which contains a lot of commands needed for working with the screen ,audio, etc, for making games. Normally the commands in that librar are not available until you install that library, and also tell Ruby to use the library inside your program.  You'll have to tell Ruby that you really want to also use the commands related to game programming in rubygame, in the "rubygame" library. You do that like this:

require 'rubygems'
require 'rubygame'
Rubygame.init
Rubygame.quit

This program does nothing but start up Rubygame and close it down again, but it should run without giving any errors if rubygame is installed correctly.

The require 'rubygame' command tells Ruby that you really need the Rubygame library, and makes it so that Ruby will look up commands in that library.  The name of the library is between quotes, because names of libraries need to be text strings in ruby. You also need a require "rubygems" before that, because the Rubygame library itself needs some stuff that's inside a different library called "rubygems".  Once the rubugame library has ben loaded, the Rubygame module that is inside the rubygame library, and all the commands it knows about became available for use.

Which means were're almost ready to start displaying something on the screen! :)

But perhaps it's better if I let you digest al the stuff I wrote above before I continue. I eagerly await your questions. :)

90
Next installment! On to a bit about handling text and some types of commands named "methods"

Ok, now we already talked about how to do simple math in Ruby. And you also know how to display something on the screen using puts.
How about working with text? That 's important for things like dialogs between characters and the NPC's, high score lists, etc.

So, let's see how to write the words The dragon eats the goat to the output window. You just do

puts "The dragon eats the goat"

Why is the text between double quotes? Because that's how the programming language can see that it's a text, and not soe insruction for what it should do. In the jargon of computer programmers, such text is called a "string" like a bunch of letters stringed together on a wire. In Ruby (but not in some other programming languages), you can also put text between single quotes, like

puts 'The dragon eats the goat'

And of course, with text strings you can do several things, a bit like how you can calculate with numbers. For example
s = "Bob's" + " goat"
puts s
will output Bob's goat when you run it as a program. The + can glue two text strings to each other, in the order given. And of course,
you can store a string in a variable, and fetch it again later, like , when you want to display it in the output  window.

Now , let's see how numbers and text strings work together.
Let's try this:
s = "The length of Bob's name is " + 3
puts s
Well, you'll get an error like this:
TypeError: can't convert Fixnum into String

Why? Because numbers and letters aren't directly compatible with each other, at least not in Ruby.  You'll have to change the 3 from a number to a text string like this:

s = "The length of Bob's name is " + 3.to_s
puts s

That's something new for you there. What's up with the  period . and the to_s after the 3?
Well, in Ruby, you can use a command like puts, and the programing language will look it up in it's currently open libraries to find what it has to do. However, you can also tell Ruby that it has to do something with an individual number or string. To do that, you put a period (.) behind the thing you want to work with, followed by the name of the command that tells what you want Ruby to do with that object. In this case , you're telling Ruby, hey, i want you to take number 3, and convert it to a text String. "to_s" is short for String. In Ruby, it's common to see many short names for commands, since they're more quick to type, and also less work to remember in the long run.

There are many more things that you can ask Ruby to do to text, numbers or values. Also, even when you tore the values into variables, you can still ask Ruby to perform the commands on them that it could do when dealing with the value direcly. Another example:

b = "Bob"
l = b.length
puts "Bob's name is " + l.to_s + " characters long"
will write "Bob's name is 3 characters long" to output. You're storing the string "Bob" in a variable called b. then You ask Ruby to take the length of that text string, that is, the amount of characters in it, and store it into a variable named l
Finally, you let  it change the length, which is a number, to text, and then glue all the parts of the text together, and then write it to output.

Commands like puts are called "functions" or  "procedures",  in the programmer's jargon. They're just instructions that the programming language looks up in the currently active libraries of the programing language, and then performs.  Commands like .to_s or .length are called "methods".  In Ruby, there's not too much difference between the two but it will help if you know the programmer's jargon a bit.

How to find out what "methods" a number or string or a value in a variable has? In other words, how to find out what ruby can do with them?  Well, in Ruby that's simple because there's also a method to get the methods, conveniently caled .methods. Just try this:
puts 3.methods
puts "hello".methods

You'll get oodles of text in your output window, all of these are the names of the methods for the number 3 or for the text "hello" that Ruby knows.
To find out what all these commands do, you can look it up in the documentation of Ruby, like here: http://www.ruby-doc.org/core-1.8.6/index.html
But for now, we don't need all those commands, but I'lll leave it up to you to explore a bit. Don't wory about using a method (command)  that Ruby doesn't know, it will simply give an error message and  stop there.

Pages: 1 ... 7 8 [9] 10 11