AuthorTopic: making video games, where do you start?, how do you stay focus?  (Read 29056 times)

Offline dragonboy

  • 0001
  • *
  • Posts: 28
  • Karma: +0/-0
    • View Profile

Re: making video games, where do you start?, how do you stay focus?

Reply #20 on: August 01, 2008, 09:17:29 pm
until you try, all you do then is speculate.

I did try several times.  I can't understand high-level nomatter how hard I try and how hard I research.

Offline Beoran

  • 0010
  • *
  • Posts: 112
  • Karma: +1/-0
    • View Profile

Re: making video games, where do you start?, how do you stay focus?

Reply #21 on: August 01, 2008, 09:30:18 pm
Sorry, but it sounds to me like you've been trying only for a short while. Please don't be too impatient. :) What exactly is the problem? If you want me to tutor you a bit, I'm game, just contact me by private message, we can set up a meeting over IRC or skype or something.
Kind Regards, Beoran.

Offline Helm

  • Moderator
  • 0110
  • *
  • Posts: 5159
  • Karma: +0/-0
    • View Profile
    • Asides-Bsides

Re: making video games, where do you start?, how do you stay focus?

Reply #22 on: August 01, 2008, 10:18:37 pm
Beoran, you're being kinda wonderful! I hope you like cookies.

dragonboy: it's strange that you can understand assembler but not a considerably easier to handle high level language. Where exactly do you get stuck in trying to make something in high level that you can do in assembler? Also, especially since you're getting such good help in this thread, why not post some of your code or game-attempts in assembler so people can critique what you're doing wrong in specific.

Also though this forum isn't about programming, I'd rather this thread ran a while more in the open than in PMs because others of us that dabble I think could benefit from this discussion. So don't worry about it being OT.

Offline dragonboy

  • 0001
  • *
  • Posts: 28
  • Karma: +0/-0
    • View Profile

Re: making video games, where do you start?, how do you stay focus?

Reply #23 on: August 01, 2008, 10:47:57 pm
Sorry, but it sounds to me like you've been trying only for a short while. Please don't be too impatient. :) What exactly is the problem? If you want me to tutor you a bit, I'm game, just contact me by private message, we can set up a meeting over IRC or skype or something.

I answered his post before I read yours.  Thankyou for those sprite opcodes you told me about.  I would like to be tutored!

Offline willfaulds

  • 0010
  • *
  • Posts: 217
  • Karma: +0/-0
    • View Profile

Re: making video games, where do you start?, how do you stay focus?

Reply #24 on: August 01, 2008, 11:20:12 pm
I'm going to just through these 2 into the mix;

Flash/actionscript = by no means a perfect language but it is superblyl documented on the internet and really very easy to use. There are loads of tutorials, even specific to gaming, available.

A pre made game engine such as Garage Games Torque engine = a fairly easy and reasonably documented head start.


Both of these suggestions are very genre specific though. What type of game are you going for?

Offline Beoran

  • 0010
  • *
  • Posts: 112
  • Karma: +1/-0
    • View Profile

Re: making video games, where do you start?, how do you stay focus?

Reply #25 on: August 01, 2008, 11:27:04 pm
Ok, so seeing we have the moderator's blessing, I'll tutorial a bit here too, on high level languages, using Ruby as an example. But please ask me relatively specific questions ,and tell me if it gets out of hand. Please open http://tryruby.hobix.com/ so you can try things I'm telling yourself. Don't worry if you want to use a different language, much of what you learn about Ruby can be used in other high level languages by changing the notation a bit.

Ok, so any game console or pc has a CPU that does the calculations, RAM memory to temporarily store data, and all kinds of input and output and storage devices you can use in various ways, like the graphics chip , the mouse, keyboard or joypad, etc. In assembler, you're working with registers, memory locations, and input and output ports. Registers are special "locations" in the cpu you can store numbers in to perform calulations to make descions based upon those calculations, and other various operations.  Memory locations are "locations", addresssed by a numerical index in the memory that you can read from or store data to. Some memory locations are "special", and connected to the various devices. Ports can be read or written to in order to communicate with the devices.

To get anything done in  assembler, you'll fill in the registers, either with constants, or by reading from ports or memory, and then you perform the needed operations, finally writing the data to memory or a port (if that is needed). It seems simple at first sight, however, you are limited to the instructions that the CPU understands. That means to get anything done you have to use a lot of different instructions to get anything done.
In a high level language, all these steps are "hidden" and simplified into one step. On a video game console, when writing in assembler, you can use the graphics chip to display sprites on the screen, etc. In a high level language, you don't access the CPU or the memory or the graphics chip directly. Rather, you let the programing language handle the details.

The most simple thing you can do in programming is math. You need math for all games (to move sprites, for collisions, etc.)
For example, in ruby, to make a sum, you would simply write it like you do in math:
1 + 2
>> 3
And you should be able too guess what 3 - 2 should do. As for multiplications, we write
2 * 3
>> 6
I know it's funny, but in most programing languages, * is used for multiplication.
For division it's like this:
6 / 2
>> 3

That's all very simple, however, what if you want to use the result later? It's best to store the result somewhere.
a = 1 + 2
>> 3
The = here is different from math. It doesnt' mean "equals", but "store", as in store into the variable called a
the sum of 1 and 2. What's a variable? Simply a named "thing" or "place" that you can use to store things in.

Now what will a + 3 do?
a + 3
>> 6
The computer remembers that we stored 3 in a , so now ,it takes the value stored in a, and adds 3 to it, giving 6

That's all fine and dandy, of course, but the burning question is of course, how do you do thing like accessing the graphics card, drawing sprites to the screen, playing music, etc? For such things, you will use 'libraries'. Libraries are pre-built  sets of functionality that you can reuse in your own program. But to use those libraries, you have to understand how to call them from the programming language you are using.

The most simple way to access functionality that is present in the language is to invoke it though a name. For example, to write something to the output you can use the name "puts",  short for "PUT on the Screen"  together with what you want to write.

puts 3
3
>> nil

You could also write puts(3) in Ruby, here it's the same as puts 3.
You're just telling the computer, hey, do this funky thing called "puts".  The computer then looks into the libraries of Ruby,
and finds that puts means you gotta write  what comes after it to the output.

Ok, that's part 1 of my very basic intruduction to high level languages. please tell me if it is too simple. More to come later based upon your questions. :)
« Last Edit: August 01, 2008, 11:58:25 pm by Beoran »
Kind Regards, Beoran.

Offline dragonboy

  • 0001
  • *
  • Posts: 28
  • Karma: +0/-0
    • View Profile

Re: making video games, where do you start?, how do you stay focus?

Reply #26 on: August 02, 2008, 01:54:07 am
Okay I'm going to try this on the Ruby program I just downloaded, but where exactly in the ruby folder is the actual program you write the codes on?

Offline Beoran

  • 0010
  • *
  • Posts: 112
  • Karma: +1/-0
    • View Profile

Re: making video games, where do you start?, how do you stay focus?

Reply #27 on: August 02, 2008, 08:56:21 am
Ok, so you downloaded the Windows one click installer for Ruby (http://rubyforge.org/frs/download.php/29263/ruby186-26.exe) and installed it? Good. Could you please tel me in what folder you installed it? (You should know since the installer normally asks you, normally it's in C:\Ruby )
You'll also have to install Gosu or Rubygame, as they are libraries to write games. I reccomend you install Rubygame, because that's what I use and know best. Rubygame for windows is here: http://sourceforge.net/project/downloading.php?group_id=172781&use_mirror=mesh&filename=rubygame-2.3.0-x86-mswin32-60.gem&65252267. T read about how to install this "gem" file, please read here:
http://rubygame.wiki.sourceforge.net/win32_install_gem
You'll have to download and install a lot of stuff before Rubygame works, so perhaps you'd like to wait a couple of days until you have given Ruby itself a solid try. But I guess you're burning with impatience, so, go ahead with installing Rubygame if you feel you "just can't wait to be king". :)

So let me explain a bit more on how to get started writing programs for a high level language. First of all, you'll need a text editor that lets you write "plain text" format. You could just use notepad, but that will be a bit hard to use because it doesn't have anything convenient to help you programing. That's why it's more easy to use a "programmer's editor". A programmer's editor will  help you because it will color the program in different colors (red, blue, gree, etc) as you are typing it to help you understand it. The programmer's editor also allows you to "run" the program, that is, make it do what you are telling it to do, by pressing a button.   

Now, fortunately for us, in the windows one click installer for Ruby, there is a programmer's editor included, called 'SciTE'. You should find that either on your desktop or somewhere in your start menu (It has a kind of a blue ball with "ribs" icon). Please start that program.  You'll have an "untitled" document to begin with. Now, let's save a file that will be our first program. In the menu, go to "File" -> "Save As". With the "create folder" button in the file dialog, let's make a folder to hold our programs, perhaps on your desktop or wherever you thin is convenient. You can call it whatever you like , like "programs". Then go inside that newly made folder by (double) clicking on i. Then type the name of the program in the  name box, again, you can call it whatever you like, but I just called it "program1.rb". The .rb at the end is important, because it will tell SciTE and the Windows operating system that that file is a ruby program, so they both know how to handle it. 

Now just type in the document
puts 123
Then save the document by going File->Save or clicking the save icon on the toolbar, or by pressing the shortcut control-s. Now, in the menu, go to Tools -> Go   or press the F5 shortcut button. A window should pop up with the following in it (among others):
123
That's the "output window" where you can see your program working. You tell it to put 123 in the output and it does so. So, that's how you can write your program and get it to run (do what you are telling it to do).

If you can get all that a working OK, then you're ready to start with the serious work. :) So tell me how you're doing, and in the next installment, I'll go further with more useful explanations on high level game programming.



 



Kind Regards, Beoran.

Offline Beoran

  • 0010
  • *
  • Posts: 112
  • Karma: +1/-0
    • View Profile

Re: making video games, where do you start?, how do you stay focus?

Reply #28 on: August 02, 2008, 09:22:44 am
Next short installment: Errors in your program

What's with errors? Evey high level programming language has some rules you have to follow for it to understand what you want it to do. Those rules are called the "syntax" of that program. If you don't stick to those rules, the programing language will not understand what you want it to do, or worse, in some cases, misunderstand what you want it to do. If the high level programming language really doesn't understand what you want it to do, it will stop running your program and give you an error message.

You can try it by making a program1.rb that contains just of this
a = 10 +
and run it (with F5 or Tools/go, remember) and this is what you'll get

program1.rb:1: syntax error, unexpected $end
a = 10 +

In other words, the programming language is complaining about the "syntax", that is, you are not following the rules. you want to store a sum into a but the sum of 10 and what? So the programming language just gives up and says: hey, you made an error there, on line 1 of your program. I'm outta here!

Let's correct our program and run it again: change it to
a = 10 + 10
puts a
And run it, and you will see "20" in the output window. No errors, since you're following the rules of the Ruby language, so Ruby understands what you want it to do for you, and does it.
Kind Regards, Beoran.

Offline Beoran

  • 0010
  • *
  • Posts: 112
  • Karma: +1/-0
    • View Profile

Re: making video games, where do you start?, how do you stay focus?

Reply #29 on: August 02, 2008, 02:56:31 pm
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.
Kind Regards, Beoran.