Need help in continuing

Started by
8 comments, last by SillyCow 11 years, 8 months ago
Hello.

As many other that appear here, I am aspiring to be a game developer (programer), and so trying to take my first steps.

First of all, I've read this topic and found it quite usefull :http://www.gamedev.net/topic/628487-so-i-want-to-be-a-game-developer/

Right now I am a computer Science student, going to my 3rd year. Related to programaing I've already have had:

- Scheme (to learn concepts)
- 3 different usages of C (data structures and all the normal things to learn, synchronizations primitives like mutexes and semaphores, and had to make a compiler for a new simple language this year, using other tools like lex, yacc and burg)
- OOP in Java
- emulated assembly (it was not quite assembly, but something adapted to learning)
- prolog
- CG (and here, learned C++ and OpenGL with glut, also how the graphics pipeline works with all the matrixes and stuff, we made a simple working 3D pacman game)

The thing is, this summer I wanted to start making simple, working 2D games. I know that by knowing how the crude of opengl I should continue twoards the 3D, but I want to have a bit of experience in learning how games work. I tried using Unity, but didnt like it because I am getting used to do things by programing, and that seemed to be the complete oposite, and wasn't able to do anything there. I found XNA to be realy accessible in terms of documentation, and as I already had visual studio from the last semester from working with C++ decided to give it a try.

In around 4 or 5 days I was able to make a simple working 2D Tetris game, and became quite happy to have something, not purely academic working.

-------------------------------------------------------------------------

Now you know the background, moving to the question:

As the next step I'd like to make sidescroling, so I have 3 questions:

1 - Can anyone explain or link, genericaly, how side scrolling works in terms of programing (or more specificaly in XNA)?

2 - My Tetris game had around 10 classes, (representing the state manager, the generic state, menu state, game state, paused state, and the game classes, block, map, piece (the block is each square) and the current moving piece), all this to a simple tetris. Now, Do a big game really has a huge ammount of classes? Like some for each level? Or am I thinking of it wrong?

3 - All of the games Ive made untill now had colision or movment based on a grid (the pacman movment was fluid, but could only change direction on intersections), so , being 2D or even 3D, how am I supposed to check for colision between lots of diferent corpses? I know it is easy for spheres, as I can go through each object and check arround the radius, but what about more complex shapes like a sprite with a transparency in 2D or a person model in 3D? Does XNA has anything to help in this situation?

Thanks everyone for the help, and sorry for the long post and spelling errors, I am not a native english speaker.
Advertisement
1. Don't know about XNA. But when I've made side scrollers, sort the objects by their x position (sideways). And then only treat the objects which are close to the player: The ones which are on screen, or close to being on screen.

2. It depends on what programming language you use. When you make your first game, don't worry about reusability and clean code. Just make a game. Writing "correct" code with no experience will take up alot of your time, and interfere with your finishing a game. Do what comes natural. Worry about code design when you make your second game.

3. Take an iterative approach. At first when you don't have alot of objects, collide everything with everything. Computers today are computational beasts, so you shouldn't run into a performance problem until you have many objects. Later you can check out algorithms like Quadtrees, KD trees, and Sparse-Matrices (You only need to choose one). I've never used XNA, but I assume it has a ready made implementaion of at least one of these.

Good luck with your game.

My Oculus Rift Game: RaiderV

My Android VR games: Time-Rider& Dozer Driver

My browser game: Vitrage - A game of stained glass

My android games : Enemies of the Crown & Killer Bees


1. Don't know about XNA. But when I've made side scrollers, sort the objects by their x position (sideways). And then only treat the objects which are close to the player: The ones which are on screen, or close to being on screen.


What seems strange to me is how can I make the movment fluid, and apply it to programing.


2. It depends on what programming language you use. When you make your first game, don't worry about reusability and clean code. Just make a game. Writing "correct" code with no experience will take up alot of your time, and interfere with your finishing a game. Do what comes natural. Worry about code design when you make your second game.


Having got a bit of backgruond from the degree, that would be a step back. Also, I want to learn how to make things well.


3. Take an iterative approach. At first when you don't have alot of objects, collide everything with everything. Computers today are computational beasts, so you shouldn't run into a performance problem until you have many objects. Later you can check out algorithms like Quadtrees, KD trees, and Sparse-Matrices (You only need to choose one). I've never used XNA, but I assume it has a ready made implementaion of at least one of these


Ok, so we really have to check colisions between everything, didn't know that. Those algorythms also cover the problem of the not regular shapes? Im going to check how that works and if XNA has anything about it.

Thanks for the help. If anyone could give more awnsers I'd apreciate it.

1 - Can anyone explain or link, genericaly, how side scrolling works in terms of programing (or more specificaly in XNA)?


Assuming you are using a tile map (or similar), you just have to draw the correct range of tiles at the correct offset according to the current "camera" position. There are various approaches to this, one is to draw the tile map to a rendertarget, but drawing an extra column, then draw that rendertarget to the screen on an offset. The best way to work this out is to draw it out on graph paper first. I don't know of any links offhand, perhaps searching for "smooth scrolling tile map" or similar may net you some good info.


2 - My Tetris game had around 10 classes, (representing the state manager, the generic state, menu state, game state, paused state, and the game classes, block, map, piece (the block is each square) and the current moving piece), all this to a simple tetris. Now, Do a big game really has a huge ammount of classes? Like some for each level? Or am I thinking of it wrong?
[/quote]

You shouldn't expect to get a perfect design at first. That is what refactoring is for. My method is to just plug away at getting something to work, then I factor out base classes & interfaces when it seems applicable. Experience will certainly cut down on the amount of this type of refactoring, but I doubt it can ever eliminate it.

My code often contains many classes, it helps seperate functionality. However, you should look for ways where composition is more useful - for example, I've never made seperate classes for each level of a game, since levels are expressed as data, not polymorphism.


3 - All of the games Ive made untill now had colision or movment based on a grid (the pacman movment was fluid, but could only change direction on intersections), so , being 2D or even 3D, how am I supposed to check for colision between lots of diferent corpses? I know it is easy for spheres, as I can go through each object and check arround the radius, but what about more complex shapes like a sprite with a transparency in 2D or a person model in 3D? Does XNA has anything to help in this situation?
[/quote]

Collision detection covers a wide range of algorithms and methods, but it is well understood and documented. I'll try and throw some search terms out that you can research if you want.

Likely the most common method are bounding boxes, more specifically AABBs (axis aligned bounding boxes). The only thing that XNA provides that might be useful for those is the Rect class.

AABBs are usually good enough (and simple to implement), but if not there are other shapes (such as capsules), and even "pixel perfect" collision detection.

For checking lots of objects, modern hardware can actually handle a lot of checks. However, when it gets to be too much, you need to start optimizing. This is where broad phase and narrow phase checks come into play. Basically this means that you can eliminate many checks right off that bat.

As objects start to move quickly, it gets a bit more complicated ;). Since checks are only done every 60th (or whatever) of a second, fast moving objects can sometimes go through other objects before a collision check is made. I believe this often referred to as "tunneling". There are a whole slew of methods to address this issue, some of them get pretty advanced in terms of maths.

Note that we still haven't said anything about collision response, just in answering the question of whether to objects are colliding (intersecting). They may be touching, or one may be inside another, or (going back to the previous paragraph) we may have determined that they passed through each other in the last frame. How we want to resolve the collision is a different matter. Here is where physics libraries come in handy, which is what I usually fall back on as this stuff is mostly over my head.

one is to draw the tile map to a rendertarget, but drawing an extra column, then draw that rendertarget to the screen on an offset.


Sorry, cant understand what are you meaning.


However, you should look for ways where composition is more useful - for example, I've never made seperate classes for each level of a game, since levels are expressed as data, not polymorphism.


That seems a god idead for me, however, if I want something that is not grid based as I asked, how can I express it as data? Reading from a txt that has the coordinates of each plataform?


As objects start to move quickly, it gets a bit more complicated ;). Since checks are only done every 60th (or whatever) of a second, fast moving objects can sometimes go through other objects before a collision check is made. I believe this often referred to as "tunneling". There are a whole slew of methods to address this issue, some of them get pretty advanced in terms of maths.


Never really thought about it, but makes sense.

As for the rest of the post, thanks for the help, I'l research a bit for the terms you wrote. I have already also found that xna can detect colisions between rectangles, and then use the transparency to make a pixel by pixel colision, so unless I rotate the sprite it shouldn't be to hard.

I've also found that we can have a mask to the sprite, that instead of being painted witch the texture has diferent colours representing body parts, and then we check this one instead of the textured one to see the part that is coliding. Is this correct in terms of programing, or is there any better way?

one is to draw the tile map to a rendertarget, but drawing an extra column, then draw that rendertarget to the screen on an offset.

Sorry, cant understand what are you meaning.


Yeah, I did a bad job at explaining what I meant smile.png. In fact, it's a bit hard (for me) to explain or understand these type of things without visuals. Your best bet is to perhaps search around for some example projects, there is something called the "RPG Starter Kit" on MSDN, it may be one starting place. Maybe if I get some time I'll try and work up a graphical example of what I meant...


That seems a god idead for me, however, if I want something that is not grid based as I asked, how can I express it as data? Reading from a txt that has the coordinates of each plataform?


Sure, that is basically how level data is stored. Note it can be XML, JSON, proprietary text format, or even a binary format. There is a utility called Gleed2d here: http://gleed2d.codeplex.com/ where you can design maps and it stores the data as XML. There may be other editors of this type, most of them seem to be grid (tile) based, but this particular one is not. You can check it out to see how they store their level data.


I've also found that we can have a mask to the sprite, that instead of being painted witch the texture has diferent colours representing body parts, and then we check this one instead of the textured one to see the part that is coliding. Is this correct in terms of programing, or is there any better way?


If it works correctly for your use case, I'd say go for it. There are many collision testing methods, the reason is because there are tradeoffs and advantages to each. Some of these tradeoffs are in efficiency, some in code complexity, and some in capabilities.

For some other examples, you may want to check these out: http://create.msdn.c...ion_2d_perpixel
If you ned help with collisions then you could use the farseer physics engine which was intended for use on .net, specifically XNA although it can be used with any renderer with some messing around.

Quick question, are you using the managed C++ on .net with XNA or using C#?

Ok, so we really have to check colisions between everything, didn't know that. Those algorythms also cover the problem of the not regular shapes? Im going to check how that works and if XNA has anything about it.


No you don't. The algorithms mentioned above save you the trouble. I was just suggesting that before you use said algorithms, use the naive approach of everything vs. everything. Just because said algorithms are harder to implement, and e vs. e might be enough at first.

My Oculus Rift Game: RaiderV

My Android VR games: Time-Rider& Dozer Driver

My browser game: Vitrage - A game of stained glass

My android games : Enemies of the Crown & Killer Bees

I havent done anything yet, but started reading some resources. The Tetris was made with C# and Xna 4.0. I haven't really learned C#, but its kind of a mix between C++ and Java, so it hasn't been realy that hard in that matter.

I never realy tought of having a level editor, but I liked that gleed2d. The link you put there is only compatible with XNA 3.1, but it seems some guys already ported it to 4.0, https://github.com/SteveDunn/Gleed2D. I also found tIDE http://tide.codeplex.com/, which seems to have a realy nice editor (although is tile based), but the documentation on the programing side is none, so I don't know how anyone is supposed to use it.


If you ned help with collisions then you could use the farseer physics engine which was intended for use on .net, specifically XNA although it can be used with any renderer with some messing around.


Also found that, seemed really good and probably will try to use it in the future.

Let's see if tomorow I don't get lazy, and actualy start trying to do anything.

edit:


No you don't. The algorithms mentioned above save you the trouble. I was just suggesting that before you use said algorithms, use the naive approach of everything vs. everything. Just because said algorithms are harder to implement, and e vs. e might be enough at first.


Yes, I understood what you said probably didn't express myself correctly. but those algorithms are ways of having the game know where each object is, and so it doesn't check for the far away ones right?

Yes, I understood what you said probably didn't express myself correctly. but those algorithms are ways of having the game know where each object is, and so it doesn't check for the far away ones right?


yes

My Oculus Rift Game: RaiderV

My Android VR games: Time-Rider& Dozer Driver

My browser game: Vitrage - A game of stained glass

My android games : Enemies of the Crown & Killer Bees

This topic is closed to new replies.

Advertisement