Bay 12 Games Forum

Finally... => Creative Projects => Topic started by: sonerohi on July 08, 2009, 07:48:10 pm

Title: Trying to make a game.
Post by: sonerohi on July 08, 2009, 07:48:10 pm
For a while, I've always tried to slowly edge myself into game programming. I would have grabbd my wallet and my cojones, and registered for a course by now, if not for one setback. Every single course and camp I've found is for people 18+, I.E. I'm going to be waiting four years before I can get started with those. I'm restricted to the Internet, where I can engage in any activity ever, so long as I click the 18+ box and provide a throw-away email account. I'm trying to figure out what the best language would be for a complete beginner, and I'd like links to any good tutorials you know. If all goes well, I'm going to regularly update this post to shamelessly plug my sub-par games.
Title: Re: Trying to make a game.
Post by: Jack_Bread on July 08, 2009, 07:56:46 pm
I recommend Game Maker. It may be crap, but it still would give you some knowledge in programming unless you keep using their Drag and Drop feature.
(http://i649.photobucket.com/albums/uu215/Jack_Bread/ZangooseSarRasp-1.png)
Title: Re: Trying to make a game.
Post by: ToonyMan on July 08, 2009, 07:58:17 pm
Program a game from in Dwarf Fortress.
Title: Re: Trying to make a game.
Post by: Vactor on July 08, 2009, 08:04:14 pm
if you just want to get right into games i would recommend using c# and XNA, this is a good tutorial for that as well: http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series2/Starting_point.php (http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series2/Starting_point.php)
Title: Re: Trying to make a game.
Post by: Duke 2.0 on July 08, 2009, 08:04:48 pm
 Indeed, start with Game Maker. From there pick up some fun programming language like Python, Java or Lua. After learning the programming basics and writing some simple programs you can start working on games of the simple sort.

 Trust me, this will take you four years. Just work hard with Game Maker and a fun language 'till things get into shape.
Title: Re: Trying to make a game.
Post by: Strife26 on July 08, 2009, 08:20:13 pm
Learn Qbasic?

I never really got the hang of Game Maker, personally.

But I did create a really cool program involving Vincent Valentine on a bike shooting stuff by messing with the pictures of the included 1942 clone.
Title: Re: Trying to make a game.
Post by: sonerohi on July 08, 2009, 08:25:28 pm
Well, 2 for Game Maker, 1 for C & XNA. Also, Toonyman-ic nonsense. I've already encountered a problem in that the button to download Game Maker 7 links back to the page that the button is on.
Title: Re: Trying to make a game.
Post by: Armok on July 08, 2009, 10:01:10 pm
I'd say python, or something similar.
If you're ambitious, Linoleum (http://anywherebb.com).
Title: Re: Trying to make a game.
Post by: Jack_Bread on July 08, 2009, 10:18:42 pm
Try this link. (http://www.yoyogames.com/gamemaker/try_download)
Title: Re: Trying to make a game.
Post by: Alexhans on July 08, 2009, 10:50:44 pm
I DONT recommend using a Game Making Engine because they're script based and it may be hard (and pointless) to go from one script based language to a real programming language.

Gamedev (http://www.gamedev.net/) is a GREAT game programming site... Check the books they recommend for beginners...

C++:
cprogramming (http://www.cprogramming.com/) Good site.
Introduction to C++ (very good) (http://www.mikeware.us/cpp/)

Also... check the roguelike development megathread here in bay12...
Title: Re: Trying to make a game.
Post by: sonerohi on July 09, 2009, 01:26:05 am
I quickly had a falling out with Game Maker do to it not supporting any sprites or sounds I tried to make myself. I'm using the Introduction to C++ link to learn, and I've gotten to the loops, acing all the reviews. I made a quick game-ish thing for guessing a randomized number (under twenty). I'm going to turn in for the night, and see if I can still ace all the quizzes in the morning. After that, more learning.
Title: Re: Trying to make a game.
Post by: Jack_Bread on July 09, 2009, 01:31:49 am
I quickly had a falling out with Game Maker do to it not supporting any sprites or sounds I tried to make myself.
Whaaaat?
Title: Re: Trying to make a game.
Post by: Duke 2.0 on July 09, 2009, 01:34:20 am
I quickly had a falling out with Game Maker do to it not supporting any sprites or sounds I tried to make myself.
Whaaaat?
Quite a few people dare to disagree. (http://forums.tigsource.com/index.php?topic=4017.0)

 Although considering the complexity of anything made to make anything resembling a game, such a feature could be in an obtuse location.
Title: Re: Trying to make a game.
Post by: Jack_Bread on July 09, 2009, 04:53:22 am
I quickly had a falling out with Game Maker do to it not supporting any sprites or sounds I tried to make myself.
Whaaaat?
Quite a few people dare to disagree. (http://forums.tigsource.com/index.php?topic=4017.0)

 Although considering the complexity of anything made to make anything resembling a game, such a feature could be in an obtuse location.
Again, whaaaaaaat?
Title: Re: Trying to make a game.
Post by: ToonyMan on July 09, 2009, 10:13:57 am
Isn't Spelunky made in Gamer Maker?  Good games can come out of it if you know what you're doing.
Title: Re: Trying to make a game.
Post by: sonerohi on July 09, 2009, 11:00:16 am
I quickly had a falling out with Game Maker do to it not supporting any sprites or sounds I tried to make myself.
Whaaaat?
Quite a few people dare to disagree. (http://forums.tigsource.com/index.php?topic=4017.0)

 Although considering the complexity of anything made to make anything resembling a game, such a feature could be in an obtuse location.

I ever said it was a world-wide problem  :-\. Besides, part of the little contract thing equated to:"all games made in gamemaker lite are property of the yoyogames people".

I've found that, thanks to the educational tutorial, I can now stumble through basic lines of code and understand what is happening.
Title: Re: Trying to make a game.
Post by: Muz on July 09, 2009, 11:37:06 am
I DONT recommend using a Game Making Engine because they're script based and it may be hard (and pointless) to go from one script based language to a real programming language.

Not really. I started off using Klik & Play, which is as noobish as game making engines go and am now working professionally with programming language. You learn (or you should learn) good programming skills from scripts, the very least in how to sort out your code. Besides, some of them are quite advanced. Game Maker has been viewed as crap by a lot of people, but really, Spelunky proves that a tool may not be so bad with a good craftsman.

I really wouldn't recommend a "professional language" unless you're either making a roguelike or an epic game. And if you are making an epic game that needs a programming language, you're better off taking a degree or at least a course in it.

Game making tools work best for hobbyists. You could create games like Jagged Alliance or LCS with one, provided you have decent programming skills. Anyway, I greatly prefer Construct (http://www.scirra.com) over GameMaker. It's easier for newbies to do tough stuff, but gives advanced users a lot more options.
Title: Re: Trying to make a game.
Post by: Alexhans on July 09, 2009, 01:55:03 pm
Little time so short answer...

LAter I'll develop...

My own experience was starting with AGS (Adventure Game Studio) Wich is a very similar to c++ script... It was a cool tool but when I had to move to real c++ I had to forget a lot of wrong concepts I had...

That's why I suggest a professional language to start with.
Title: Re: Trying to make a game.
Post by: Sowelu on July 09, 2009, 02:13:41 pm
I started out by downloading a MUD server source, and hacking around in it to add stuff (I used ROM2.4).  If you want to get a feel for C, hacking up someone else's C code is a great way to start.

I recommend C# / XNA, too.  It's good stuff.  XNA is actually somewhat easy to use (although it still takes some experience to make an actual playable thing out of what you start with).

If you want to have a game within a couple months though, definitely go with Game Maker.
Title: Re: Trying to make a game.
Post by: sonerohi on July 09, 2009, 05:48:45 pm
I've run into a rough patch in understanding switch-cases. Can someone help me out with it?
Title: Re: Trying to make a game.
Post by: Ohaeri on July 09, 2009, 05:57:49 pm
I've run into a rough patch in understanding switch-cases. Can someone help me out with it?

What exactly do you need help with: understanding theory, or syntax? Theory I can help with, but probably not syntax as I've only programmed in Java and C++ and it's been a few years.
Title: Re: Trying to make a game.
Post by: qwertyuiopas on July 09, 2009, 06:35:18 pm
Code: [Select]
switch(statement that is evaluated to a number)
{
  case #:
    (code)
  case ##:
    (code)
  default:
    (code)
}

Unless you end a case with break or return, it will also run the next case.
So, for example, to count backwards from a small number,
Code: [Select]
int n=(get number however you feel like)
switch(n)
{
  case 5:
    (output 5)
  case 4:
    (output 4)
  case 3:
    (output 3)
  .....
    break;
  default:
    (output "The number must be between 1 and 5, inclusive)
}
The code starts at the matching label until it reaches either return, the closing }, or break.

Often, people will use #define to set a (usually) all-caps word to a number so rather than case 5:, they use case WOODEN_DOOR:
Title: Re: Trying to make a game.
Post by: sonerohi on July 09, 2009, 09:24:55 pm
Qwertyuiopas post helped a bit. I still don't get what exactly they would be useful for, or how they count down. Wouldn't it be easier to put in the code for "if n > 0, -1"? That way, it loops downward until n=0.
Title: Re: Trying to make a game.
Post by: Alexhans on July 09, 2009, 09:30:48 pm
It doesn't count down.  It's as if it were a set of if/else where it choses the exact value and compares it until it founds a match (Or doesnt and uses the default option).

Don't get mixed up between loops (while, for, do) and selections (If, else, case)
It's useful:
Imagine a menu:

Main Menu
1. New Game
2. Load Game
3. Highscores
4. Exit


You CAN do if else but case is more organized and easier to read and change. 
Title: Re: Trying to make a game.
Post by: sonerohi on July 09, 2009, 09:39:15 pm
Ooooooooh. Now I see the practical use of it! Qwerty made it sound like a countdown. Well, now that that is cleared up, it is time to integrate it into my code.

Incidentally, I hit up Barnes and Noble for some tutorial books on C++ and only found books on C#. It would seem that C# is more expansive, but still uses a lot of syntax from C++, so it would be beneficial to learn C++ first. My question is, what does C# offer over C++ that would be more useful?

Also, take some sympathy on me for this question as I have oceans behind my ears given that I'm 14 and started 2 days ago. What,exactly, must be done to make something in C++ be more than text based? Is it possible? What programs would I need in addition if it is?
Title: Re: Trying to make a game.
Post by: Alexhans on July 09, 2009, 10:03:43 pm
Incidentally, I hit up Barnes and Noble for some tutorial books on C++ and only found books on C#. It would seem that C# is more expansive, but still uses a lot of syntax from C++, so it would be beneficial to learn C++ first. My question is, what does C# offer over C++ that would be more useful?
MSDN is your friend! (http://msdn.microsoft.com/en-us/library/yyaad03b(VS.71).aspx)

One VERY RELEVANT feature is that c# wraps up any "memory trash" that may remain... like java.  So you don't have to be THAT careful as you had to be in c++ regarding strings and other stuff.

Quote from: sonerohi
Also, take some sympathy on me for this question as I have oceans behind my ears given that I'm 14 and started 2 days ago. What,exactly, must be done to make something in C++ be more than text based? Is it possible? What programs would I need in addition if it is?
It's not about programs but about libraries or GDI. 
There's some libraries you can use to "draw" things using a c++ compiler.
allegro is a library specifically designed for game making.
DirectX and Opengle are other Development kits to make graphics.
There's also GDI "system" that use DOS/windows functions to make graphics. 

I don't recommend you to focus on graphics just yet.  Make sure you fully grasp the basics of C++ to advance... Step by step :)

I hope I would've started at 14...
Title: Re: Trying to make a game.
Post by: IndonesiaWarMinister on July 10, 2009, 04:35:09 am
Quote
I hope I would've started at 14...

Did you just ordered me to learn C++??

Negative, sir, I'll learn Construct / Python + Rabbyt first.
Title: Re: Trying to make a game.
Post by: qwertyuiopas on July 10, 2009, 12:01:05 pm
Ooooooooh. Now I see the practical use of it! Qwerty made it sound like a countdown. Well, now that that is cleared up, it is time to integrate it into my code.

Incidentally, I hit up Barnes and Noble for some tutorial books on C++ and only found books on C#. It would seem that C# is more expansive, but still uses a lot of syntax from C++, so it would be beneficial to learn C++ first. My question is, what does C# offer over C++ that would be more useful?

Also, take some sympathy on me for this question as I have oceans behind my ears given that I'm 14 and started 2 days ago. What,exactly, must be done to make something in C++ be more than text based? Is it possible? What programs would I need in addition if it is?

The result is a countdown if you arrange it in decending order and do NOT return/break from the higher numbers.
Usually, you will break or return(depending on the use) after every case, and in that situation if/else if/else works.

Here is a better example(I hope) somewhat like a roguelike.

A door can be broken by explosions, but a player can also kick a door down.
Both have the same result, but the player may fail to kick down the dor, and if they succeed, they get skill.
The diffrent cases are assumed to have been #defined elsewhere.

KICK_DOOR uses the "fall through" thing so that the program flow continues through DOOR_BROKEN, doing both.
The return; at the end of DOOR_BROKEN ensures that the program does NOT dontinue to do OTHER_ACTIONS, although break; would also have worked if there was something that had to be done after the switch() before the function return;s.
Code: [Select]
switch(n)
{
  case KICK_DOOR:
    if(failure)return;
    do_some_skill_up_stuff();
  case DOOR_BROKEN:
    break_door();
    return;
  case OTHER_ACTIONS:
}

Edit:
The code is the same as
Code: [Select]
switch(n)
{
  case KICK_DOOR:
    if(failure)return;
    do_some_skill_up_stuff();
    break_door();
    return;
  case DOOR_BROKEN:
    break_door();
    return;
  case OTHER_ACTIONS:
}
Title: Re: Trying to make a game.
Post by: SolarShado on July 10, 2009, 04:36:45 pm
Just my opinion, but I never use switch-case blocks. Seems like unnecessarily compicated syntax to do basicly the same thing as a string of if-else blocks. Plus if-else blocks let you use any boolean expression instead of having to use a number. I'd probably end up making a bunch if-else blocks anyway to come up with the number to feed to the switch block anyway.

Java-using seventeen-year-old here, BTW.
Title: Re: Trying to make a game.
Post by: Alexhans on July 10, 2009, 04:46:13 pm
It's a matter of opinion if you feel is tidier or not...  BUT, switch IS faster.
Title: Re: Trying to make a game.
Post by: qwertyuiopas on July 10, 2009, 04:58:28 pm
....
Ugh. I lost my post.

Summary of lost data:
Switch/case statements are best for state varables, not number comparison.

Actual code, from a win32 program, poorly written:
Spoiler (click to show/hide)
Title: Re: Trying to make a game.
Post by: Alexhans on July 10, 2009, 05:00:12 pm
lol, qwertyuiopas...

I'm studying the win32 api and failed to mention that it's used to retrieve messages... . :P

Title: Re: Trying to make a game.
Post by: termitehead on July 24, 2009, 02:28:29 pm
Just my opinion, but I never use switch-case blocks. Seems like unnecessarily compicated syntax to do basicly the same thing as a string of if-else blocks. Plus if-else blocks let you use any boolean expression instead of having to use a number. I'd probably end up making a bunch if-else blocks anyway to come up with the number to feed to the switch block anyway.

Java-using seventeen-year-old here, BTW.

It's probably a good idea to do that if you only have 2-4 different branches to deal with.  Once you get to 10+ it gets silly to try to do a series of if statements in my opinion.  Especially when it is really mundane stuff where all you need is different blocks of code for different values of a variable
Title: Re: Trying to make a game.
Post by: SolarShado on July 24, 2009, 04:48:32 pm
Oddly, I've reciently started using switch blocks. I'm working on a new project and using a lot more numerical variables than ever before. I also suddenly have no trouble remembering the exact syntax, which, I must admit, saves typing. But I still think it looks ugly.
Title: Re: Trying to make a game.
Post by: qwertyuiopas on July 24, 2009, 06:17:29 pm
It's ugly, in many cases, but it can look better than an equal amount of ifs.
Not that there is much diffrence in functionality when simply comparing the state of a variable...

Certainly, it ensures to readers that in amongst the else if(var ==???) there isn't else if(othervar != ???), and it can be clearer by isolating just the number/number-symbol.

Also, it can be used for clever hacks.
Did you know that switch-case has no problem if one case is in a nested if or loop?

I read it being used in that way for some clever coroutine thing, to jump straight into the loop after the first time. It's more acceptable than a goto, I guess.
Title: Re: Trying to make a game.
Post by: codezero on July 26, 2009, 09:36:44 pm
I started with qbasic, who's modern equivalent is freeBASIC. magellans' roguelike 'Prospector'(check it out, http://www.bay12games.com/forum/index.php?topic=34943.0) is written in freebasic. But if you've already committed to C there's not much point changing, they're fairly similar languages(even speed-wise), and freebasic probably isn't even any easier. Some good points of FB though are built in graphics functions and it's open source, with a friendly community. A bad(?) point is limited oop support in it's current state.

Example code:
Code: [Select]
select case n
case kick_door
if roll_to_kick() then
do_some_skill_up_stuff()
break_door()
end if
case door_broken
break_door()
end select
Select case auto breaks after each case, so there's some extra code there, but I wouldn't have set n up like that in the first place using fb.
Title: Re: Trying to make a game.
Post by: Alexhans on July 26, 2009, 10:59:00 pm
It's a matter of opinion if you feel is tidier or not...  BUT, switch IS faster.
Title: Re: Trying to make a game.
Post by: sonerohi on July 29, 2009, 04:36:41 pm
Alright, I had to take a break from learning for a while there (was away from my home computer with code::blocks and all my notes and such), and I'm hitting roadblocks again, or rather, I've passed the roadblocks because I had my ID on me, but I don't understand why the roadblock was there.

Structures: These are basically to be used for things like databases on a specific thing or person, right? Like, for example, my profile page. All the different int's and float's for my post count and activity % are all just part of the database that is Sonerohi.

Arrays: The only thing I can tell about these are that they are used as side-by-side variables, basically. So, if I wanted a 3-d game that had 100 tiles in width, 100 tiles in length, and 100 tiles in depth, I'd need a three dimensional array, right? The tutorial I'm using says that if the last slot in an array is filled, then there is a chance that the next space the memory is allocated to could be anywhere, which has the potential for bad things. So, I always need 1 extra slot in an array to prevent catastropich phail. The example code is pretty well filled up with comments that I can't make much sense out of how to make a 2d array that actually functions right, let alone a 1d array.
Title: Re: Trying to make a game.
Post by: Vactor on July 29, 2009, 08:21:19 pm
i would need to know what you're trying to do with the array, and what you're having trouble with to help, also as far as structs go are you using C# or C++? 

Title: Re: Trying to make a game.
Post by: qwertyuiopas on July 29, 2009, 09:20:37 pm
Arrays?

In C and C++, they are 0-based, meaning the first element is 0, and the last is n-1.

There is no such thing as "the last element could be anywhere".

However, especially in C, where the compiler doesn't care if you treat an int as a pointer and then a char(though for the char it will probably convert it automatically), you can give a negative array index, or one greater than the array bounds. The issue is that the computer didn't give all it's RAM to storing your array. There are other numbers in there as well.

Great example: I had an ASCII pong-like thing(a bouncing highlight as an example test), but it would go one over on the right side. This was not a real problem unless it hit the lower right corner.
If it did, it would overflow the array and write the background colour of a nonexistant tile to be something.

This would not be much of a problem, except that that particular memory location was used for something else: The "ball"'s X velocity.

If it was something else, for example, a pointer stored there, it could severely mess up the data, and when the program next tries to access the pointer's target, it would likely edit a random bit of the memory. This is more than likely to cause a segfault if it had a pointer of it's own and it was "relocated" to uninitialized memory, or if the change caused the program to try to write over the portion of memory where itself was stored.

In some of the worst cases, a corrupt pointer corrupts another pointer that corrupts another pointer and so on until one causes a segfault.


Just remember:
For strings, they terminate with an invisible character 0 so a 8 char string needs 9 bytes of storage, but otherwise 8 chars of binary data only needs 8 chars of array. The diffrence is that it is stored in array[0] to array[7] instead of [1] to [8].

Naturally, not all programming languages use 0-based arrays, but those that don't are generally in the category of BASIC and some script languages.



A structure is just a bunch of variables grouped in a single memory location so you can pass a pointer to the first and get access to them all(AFAYNTN(As Far As You Need To Know), just pass a pointer to a struct, or even a whole struct, and everything stays together), but more importantly, structs can be allocated/created all at once and are kept together automatically, and you can have a single array of structs rather than an array of values for each value that would be in the struct.





I'm not a teacher, so if you didn't learn anything, it's the way I explained it.
Title: Re: Trying to make a game.
Post by: sonerohi on July 30, 2009, 11:03:22 am
Well, you clarified structures, and you explained the catastrophic failures that could occur by overflowing the array. Besides that, I didn't manage to catch much.

I'm using C++, and I'm not specifically trying anything yet with them, but I need to understand all about how they function and how to make them function.
Title: Re: Trying to make a game.
Post by: Vactor on July 30, 2009, 05:16:39 pm
so for making your array of a 100x100x100 gridspace you would want to declare an array A[100][100][100].  You might want to leave yourself an extra line along the edges so that if anything is leaving the gridspace it can move into that line, and you can have code to bump it back in before it can move again, so you would go with A[102][102][102]  this gives you three dimensions in the array from 0 - 101.

I don't know C++ but maybe i'll help you figure out using an array
maybe something like this:

Code: [Select]
myArray = new int[102][102][102];
for (int x = 0; x < 102; x++)
     for (int y = 0; y < 102; y++)
          for (int z = 0; z < 102; z++)
myArray[x,y,z] = random.Next();

this (in C#) would cycle through the entire array, assigning a random int to each point in the array.

You could also manually fiddle with a particular part of the array by using its grid coords:

Code: [Select]
myArray[23,84,35] = 5;
as far as keeping something in the array, lets say you have something moving around, at the end of the cycle have a piece of code that checks to see if the moving object is in the edge row/column/page, and if it is have it move it back away from the edge at least one space.

It isn't necessary to use a 3d array to deal with 3 dimensions, you could, for example, have a series of objects that record their own 3d location, which are then rendered using their locations as a transform matrix.