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 ... 8 9 [10] 11

91
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.

92
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.



 




93
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. :)

94
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.

95
Ben2theedge, that's  good advice that even I have problems to adhere to for my hobby project. Gotta focus a bit more.

Yeah, it's true that gamemaker is even easier, for impatient people. Dragonboy,, if you are very impatient, you could try that first.

Of course , you need an API (that is, libraries) to write games in a high level language. That's what Pygame, Rubygame, or Gosu are good for, they really make game programming as easy as it can be, and you don't need to know any C or C++, just Puthon or Ruby, which are all easier to use and learn.

Dragon boy, you're in an interesting situation, knowing assembly but nothing more high level. If you want to learn how to program in a high level language, you'll have to learn the basics first, before you can go on and write a game. It's the same for assembler, really. In short, have a little patience with learning a language. That's what those "Hello world" examples are for, to give you an idea how to use the language.

Did you ever try to write Hello world in assembler? Look here for hello world for DOS assembler:  http://www2.latech.edu/~acm/helloworld/asm.html. That's 17 lines!

In Ruby it's just

puts "hello world"

That's the whole advantage of a high level language, no need to bother with details or opcodes, you use a high level view, in which everything can be  handle like an object, which you give commands to do things, and make queries from. But don't 'expect those languages to be like assembler. High level programing is somewhat different from assembler, you'll just have to grab the cow by the horns, and open your mind for something new. 


In Ruby, using Rubgame, managing sprites can be as easy as:
 
sprite_1 = Sprite.new(10, 20, "image1.png") # Make a new sprite at this position and with this image file loaded
sprite_2 = Sprite.new(30, 40, "image1.png") # Make a new sprite at this position and with this image file loaded
if sprite_1.collide_sprite?  sprite_2  # if sprite 1 collides with sprite 2 do something
 puts "Boom!" # just an example
end

How much easier do you want it? There are competitions in which people are able to write a game in
Python with Pygame or in Ruby with Rubygame or Gosu in only one weekend, but the people who do this,
did learn one of those languages first.  If you really don't have patience to learn how to program, then you don't
stand a chance to successfully write a big game.

Don't knock it until you have tried it! Install ruby and gosu or rubygames,  python and pygames and give both languages
a spin to see what you like best. If you choose Ruby, I'll be able to mentor you for a while (together with anyone else who
wants to learn how to make games in Ruby), but not on this mailing list. Please send me a private message for that.

96
Exactly, assembly is only for programming for a very old console, you don't need it anymore these days to make a game. Gamemaker is not free, it's nor platform independent, and also, it's programming language is not something you will be able to use later for, say, a job interview. Ruby and Python are amongst the top 10 most widely known languages, and you can use them, together with the right libraries to make games relatively easily, without having to mess with all the low-level details. And Python or Ruby might help you land a job as a programmer later on. So I recommend you use either of those languages.

Oh yeah, the try ruby online link I gave you is working again, see how you like programming in a real high level language.

And you also have the Gosu development game library for ruby, which I hear is also very nice.
http://code.google.com/p/gosu/

In this tutorial, a character is moving over a background, and that in 30 lines of Ruby code:
http://code.google.com/p/gosu/wiki/RubyTutorial

If you'd try to do that in assembler for a console, I bet you'll need 300 lines or more! Why bother with assembler then? Most people don't have a SNES or a Megadrive anymore.  If you use Gosu or Rubygames, you can distribute versions for Windows, Mac OS X and Linux , all from the same source code, without any problems. 

97
First, take a deep breath.

First of all, it takes many years to make a full length video game if you do it alone. Are you willing to invest that effort, knowing that , along the way, you'll probably have to sap your design several times and may have to start from scratch several times?

Can you program? What programming languages do you know? If you don't know how to program, you'll either have to learn how to, or you will have to find a programmer who is willing to work together with you. Both of these are hard. If you want to learn how to program and make games quickly, yet with complete flexibility, I reccommend either Pygame (Python programing language) http://www.pygame.org/ or Rubygame at http://rubygame.sourceforge.net/  (Ruby programing language). If you want to hire a programer, you'll need money. No programmer is willing to work fro free on an idea that is not his own or not close to his own. :)

To learn Ruby, you can start with an online demo of it here:
http://tryruby.hobix.com/ (hmm, seems to be fdown now)

You can get Ruby for windows here:
http://rubyforge.org/frs/download.php/29263/ruby186-26.exe

For Python, I don't know very wel, since I prefer Ruby. :)

Once you learn either Python or Ruby, contact me again, and I'll tell you how to go at it in detail. First you have to learn how to walk before you can run. :)

98
General Discussion / Re: Tactical RPG Grid Patterns
« on: July 21, 2008, 03:23:40 pm »
There are no popular tactical RPG's that allow you to control only one character at the time thoughout the game. If you have only one controllable character on a grid it's not a tactical RPG but a Roguelike RPG. You have to understand what Helm is saying. You should try to stick to the staples of the genre and try to make a few interesting variations on the main theme. It's good that you'll make the movement movement point based. As for weapon attack patterns, why not make it a lot easier and give the weapons a minimum and maximum range? 

Oh, and if you want to see how a TRPG is made, why not get the source code of the open source tactical RPG Battle for Wesnoth, and see how they do it. I'm sure you'll get inspiration from that game. It's specific variations are a hex based grid, and totally attacker-determined damage. Units have generally have a the same defense ratings, only different HP. To hit % is determined by the unit's nature and the terrain the unit is on.

http://en.wikipedia.org/wiki/The_Battle_for_Wesnoth
http://en.wikipedia.org/wiki/Tactical_role-playing_game
http://en.wikipedia.org/wiki/Roguelike



99
General Discussion / Re: Tactical RPG Grid Patterns
« on: July 19, 2008, 06:45:35 pm »
Sorry to sound a bit harsh, but I think that all of this looks very difficult to remember for something that isn't a board game.
The only game that I know that uses a similar approach is the old Gameboy game "Castle Quest", and that's
a very obscure game.
http://www.gamefaqs.com/portable/gameboy/home/929600.html
You should s]emulate it[/s]get it somewhere to get an idea of what it's like.

Most tactical RPG's use a simple combination of "walking range" though "movement points", combined with an "attack range" which you could express in  "range points". A diagonal move usually costs 2 movement points, a straight one 1 movement point. The same goes for attack range points.

For the idea of a chance to a critical attack to be higher when the character hasn't moved very much,, you could make the critical attack rate proportional to the amount of movement points left. You could even range in the remaining "range points" for a ranged attack or a spell, as to make a spell or ranged attack more effective at point blank range. Say, say critical hit%  = 1% + movement point% + range point%.

Well, I hope that my suggestion is helpful to you. I really don't want to discourage you, I just think that for tactical RPG's there are some generally accepted conventions that most players will consider essential. While it is very creative to stray from these conventions, it is also risky and may make your game difficult for people to "get started", and thus, unpopular.

100
General Discussion / Re: Platformer Camera
« on: July 17, 2008, 04:08:29 pm »
Actually, a simple way to get the camera to behave is to have certain tiles on your tile map act like camera (invisible) scroll block tiles. When the viewport collides with one of those blocks, further motion is not allowed in the direction of the "scroll block tile". That way you can design your levels in a very flexible way.

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