2D Scrolling Engine Question

KidTsunami
Unregistered
 
Post: #1
Hey, another question guys. First, the relevant info you need before analyzing my question:
a. I am working on an action/adventure game, the best way to visualize the way the game will look is by thinking of Zelda: A link to the past.
b. I wrote a small amount of code and had asked a question on the forum, and the openGL thread caught my eye. So I plan on using openGL for graphics instead of just straight carbon like the book.
c. The aforementioned book is Mac Game Programming by Mark S. (the book is lying around here somewhere and I'm not trying to butcher his name so we'll leave it at S...)

So, the issue is, I have been thinking over the idea of displaying levels in openGL and was wondering if just loading a single image of the level (as in the whole level, intact, not in tiles) into openGL and using the viewpoint for the scrolling was a good idea.

I want to do this so I can have more detailed environments not constrained by the use of tiles. And also the idea of scrolling involving just changing the viewpoint sounds cool. This would also lend itself to silly things like zooming in to the level from far away. But I don't want to do this if it will affect performance or is just a stupid idea.

Btw, you guys are great and really helpful, I have learned an awfully large amount from just reading this forum. Thanks a lot everyone.Wow
Quote this message in a reply
Member
Posts: 110
Joined: 2002.04
Post: #2
Quote:Originally posted by KidTsunami
o, the issue is, I have been thinking over the idea of displaying levels in openGL and was wondering if just loading a single image of the level (as in the whole level, intact, not in tiles) into openGL and using the viewpoint for the scrolling was a good idea.

I want to do this so I can have more detailed environments not constrained by the use of tiles. And also the idea of scrolling involving just changing the viewpoint sounds cool. This would also lend itself to silly things like zooming in to the level from far away. But I don't want to do this if it will affect performance or is just a stupid idea.

Btw, you guys are great and really helpful, I have learned an awfully large amount from just reading this forum. Thanks a lot everyone.Wow


1. Use tiles... or prove to me WHY not using tiles could POSSIBLY BE better?

Why I say this...
Common beginner mistake... WOW I have a GREAT idea I won'y use tiles... I will be different from all the games that came before...ummm sure what ever...

Ok all those hits games your looking at clone used tiles for more reason then just that they were on consoles...

Lets reasons for tiles.
a. less art to create.
b. MUCH SMALLER DOWN LOADS
c. You can do things like animate one tile...
and not have to animate a huge back ground.
d. smaller art takes up less RAM and VRAM... you did say you want to use OPEN GL... didn't you?
Well OPEN GL provides 2d/3d hardware acceleration.
It also stores the ART in VRAM...
So on older machines you have a limited about...
You are also limited to how big a texture map you can load.
Some cards support a max of 256x256
Newer cards are bigger... some of these new card have driver bugs and tend to crash with bigger texture.... SO you need to use tiles for OpenGL games.
e. Looking at some of the Square Soft RPGs... they prove that a tile based game can look as good as any none tile based art.
f. Making changes to small images is easier then edit big pictures.

AND>... Im not also guilty of making this I should not use tiles... in my first major 2D game... DEATH FROM ABOVE....
See http://www.plaidworld.com

This is probably the BIGGEST mistake I ever made...
IF I had not used big pictures...
the app would use less ram...
the levels would have been much bigger and more creative...
the game would have been a all over better game.
the game could have been hi/resolution and NOT pixel doubled.
The game MIGHT have been a hit instead of a flop :-)

Now look at my other game Project Magellan.
It used a irregular shaped tile system.
Game looks great... but technically its just a variation on a tile based game...
PM is like 5? years old now.

Ok... Using OpenGl for you game...
Good choice it will work fine.
You might want to look into a game framework like SDL...
etc which will handle all your GL set up and all other annoying parts of game making for you...

- Mac Lead ZeniMax Online Studios
- Owner Plaid World Studios
- Resume: http://www.chrisdillman.com
Quote this message in a reply
KidTsunami
Unregistered
 
Post: #3
Thanks, yeah those are good reasons. But I was checking out your project magellan shots and I was wondering how you displayed the castle in the back of that one shot. Was that tiles? I just might be that stupid but whatever, just wanna know Blink

Another newbie question, could I get a link to info on SDL, I've heard it mentioned a lot but haven't seen any links.
Quote this message in a reply
Member
Posts: 110
Joined: 2002.04
Post: #4
Quote:Originally posted by KidTsunami
Thanks, yeah those are good reasons. But I was checking out your project magellan shots and I was wondering how you displayed the castle in the back of that one shot. Was that tiles? I just might be that stupid but whatever, just wanna know Blink

Another newbie question, could I get a link to info on SDL, I've heard it mentioned a lot but haven't seen any links.


1. you can download PM and use RESEDIT or some resource viewing app to see all the art work.
Im not sure what you would use on OS-X tho...

2. The castle level has one big repeating background image I think.
whole picture is like 640x? the castle is a another tile on top of the back ground.

Honestly the best levels of the game are the ones where we made everything out of smaller tiles that could be put together in different ways... this lets us be more creative in the level editing.

3. SDL

http://www.libsdl.org/index.php

Its cool trust me Smile
There are a few more systems like it also..

- Mac Lead ZeniMax Online Studios
- Owner Plaid World Studios
- Resume: http://www.chrisdillman.com
Quote this message in a reply
Founder
Posts: 1,138
Joined: 2002.04
Post: #5
ChrisD is right. For SDL check out FAQ or link section.

>So I plan on using openGL for graphics instead of just straight carbon like the book
I don't program anymore, but I think that sentence compares Apple and Oranges.

>I'm not trying to butcher his name so we'll leave it at S...
That's OK, since I can't pronounce it. Sorry Mark!

>if just loading a single image of the level (as in the whole level, intact, not in tiles) into
>openGL and using the viewpoint for the scrolling was a good idea.
I'll go out on a limb and try to answer this, but I am sure someone smarter will set me straight.

If you have one large texture to represent the level, sure it "may" scroll around quickly, but is that the most important factor? For example, how will you have "layers"? What I mean is ONE image and your sprites will seem to be walking on everything. (in simple terms.) If you use some sort of tile engine, you can have your sprites moving over, under, etc other objects. (ie interact with the world) You can also combine tiles to create new tiles. For example, place a ground tile, and then a tree, a bush, a stump, etc over that.

I suppose someone might say, have multiple images for various layers. But that sounds like a lot of overhead.

>I want to do this so I can have more detailed environments not constrained by the use of
>tiles.
Tiles can offer rich backgrounds. See the thread on pixel art tutorial. When done right, people don't even notice the "grid" that the tiles are in.

Next point is editing the world. With tiles, you can make a tile editor and start making your worlds (or allow gamers the possibility later) The tile engine can in fact be the basis of your game engine.

I do believe that some people have used OpenGL for tiles by and mapping textures to rectagles. So one image contains your tileset, but you are using OpenGL's speed advantage to map/draw out the tiles onto the gaming screen. I'm not qualified to say if that is better or worse than the approach in Mark's book.

BTW, read up on CocoaBlitz, and Allegro as it might be suitable for you.

Cheers

p.s. If my advice is really bad, please edit or delete it.
LOL

Carlos A. Camacho,
Founder
iDevGames
Quote this message in a reply
Member
Posts: 110
Joined: 2002.04
Post: #6
Quote:Originally posted by Camacho

p.s. If my advice is really bad, please edit or delete it.
LOL


LMAO :-)

- Mac Lead ZeniMax Online Studios
- Owner Plaid World Studios
- Resume: http://www.chrisdillman.com
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #7
A 32-bit 1024x1024 texture is 4MiB. Since I'd estimate you'd need around 4096x512 to do a reasonably detailed scroller background, that's 8MiB of VRAM (over 4 textures). Since old cards only have 8MiB of VRAM, you're probably out of luck for doing that at any kind of speed, particularly given you have to have sprites, UI graphics, &c in VRAM on top of your backgrounds.

And Carlos is right, if you want to do parallax, you'll need an extra texture for each layer...
Quote this message in a reply
Founder
Posts: 1,138
Joined: 2002.04
Post: #8
OSC gives me a nice crumb with "And Carlos is right, if you want to do parallax, you'll need an extra texture for each layer..."

Cool!

Look at me, I am dancing with joy!!! (And I am nude)

I was also going to comment on the need for lots of VRAM to hold all those maps. So as ChrisD said, not practical thus the world for the moment (and last NN years) uses tiles.

BTW, KidTsunami. Don't be down with any answers you get. Keep asking questions as it is the only way to learn (but do check the FAQ)

Cool

Carlos A. Camacho,
Founder
iDevGames
Quote this message in a reply
KidTsunami
Unregistered
 
Post: #9
Thanks for all the advice everyone, looking over everything I've settled with openGL and SDL, I plan on seeing if I can get a basic program running those tonight.

Since I'm using openGL, I want to make sure I take advantage of the features as much as possible. So I have a few questions.
1) I definitly plan on using lighting (I want to have day and night, with a realistic change in lighting). I have the red book, and reading the chapter on lighting, I don't think I'll have too much trouble, but are there any specific tutorials out there on lighting 2D games with openGL?

2) Would using separate "planes" for each sprite be too much overhead? I want to use the ability to separate plans to possibly do scaling and rotations with my sprites.

3) I was thinking of having a level layer and then an object layer, which would really be larger than normal sprites, for large trees and other objects that don't fit the normal size of a tile. Is this a good idea, or should I split them up into tiles and make the extra layer like that?

4) Another level musing... I was thinking of having a layer that didn't have graphics but just set the collision setting for each tile. Or should I just have collision settings (or values) tied to each graphical tile?

5) Multiple levels, is there an easier way to do them then have a "CurLevel" value for the player, and he can't move from one level to another unless he is on a special stair tile?

6) Along with relatively realistic lighting, I was hoping to incorporate some weather into the game, (I am going to have some farming in it, might as well :-p). The question is, would a separate sprite for each snow flake or rain drop be stupid? Or should there be some sort of layer I have that is just a scrolling image of snowflakes falling?

I think thats enough for now. A note on the levels, I do think my game design would work without the notion of separate levels, but since you have convinced me of using a layered tile engine, I believe I should incorporate levels to make sure my game is atleast on par with most 2D based adventure games Ninja
Quote this message in a reply
Member
Posts: 110
Joined: 2002.04
Post: #10
The Sleepy Bunny Answers.

Quote:Originally posted by KidTsunami
Thanks for all the advice everyone, looking over everything I've settled with openGL and SDL, I plan on seeing if I can get a basic program running those tonight.

COOL

Quote:Since I'm using openGL, I want to make sure I take advantage of the features as much as possible. So I have a few questions.

1) I definitly plan on using lighting (I want to have day and night, with a realistic change in lighting). I have the red book, and reading the chapter on lighting, I don't think I'll have too much trouble, but are there any specific tutorials out there on lighting 2D games with openGL?

1. not that I know of.
2. Lighting 2D should be no different from 3D.
3. NeHe... has lot of GL tutorials.
We have a link to Mac OS version of those somewhere on this site.

Quote:2) Would using separate "planes" for each sprite be too much overhead? I want to use the ability to separate plans to possibly do scaling and rotations with my sprites.

Planes?
Is that somting in the red book?

You can set tiles back to front by setting there z order.

You can make layers...
Say one layer is over the other and they each have a different rotation.
So that will work fine.

I do things like that in BANG!.

Examples... normal layers and HUD layers that never scale or rotate...

Quote:3) I was thinking of having a level layer and then an object layer, which would really be larger than normal sprites, for large trees and other objects that don't fit the normal size of a tile. Is this a good idea, or should I split them up into tiles and make the extra layer like that?

Hmm the layer... if it helps you layout the game and levels use it.
Otherwise you can build a FREE form tile based game.. like PM..
Meaning there is no square GRID tiles get places anywhere.
Tiles have a type and or layer they belong to that determines how they interact with other tiles/sprites.

So you need not base your world on Arrays etc...

Quote:4) Another level musing... I was thinking of having a layer that didn't have graphics but just set the collision setting for each tile. Or should I just have collision settings (or values) tied to each graphical tile?

If say your storing everything in arrays... this would work just fine.
I am considering it for a tile based RPG right now.

Quote:5) Multiple levels, is there an easier way to do them then have a "CurLevel" value for the player, and he can't move from one level to another unless he is on a special stair tile?

Uhhh WHAT?
What could be easier then what you just suggested? Smile
That sounds great to me.

Quote:6) Along with relatively realistic lighting, I was hoping to incorporate some weather into the game, (I am going to have some farming in it, might as well :-p). The question is, would a separate sprite for each snow flake or rain drop be stupid? Or should there be some sort of layer I have that is just a scrolling image of snowflakes falling?

You can probably get away with the separate sprite approach...
err its called a particle system.
You can make one for explosions and blood splaters and snow etc..

Quote:I think thats enough for now. A note on the levels, I do think my game design would work without the notion of separate levels, but since you have convinced me of using a layered tile engine, I believe I should incorporate levels to make sure my game is atleast on par with most 2D based adventure games Ninja


Well a LEVEL?
could be just a room in dungeon,,,

- Mac Lead ZeniMax Online Studios
- Owner Plaid World Studios
- Resume: http://www.chrisdillman.com
Quote this message in a reply
KidTsunami
Unregistered
 
Post: #11
Could you possibly flesh out how a tile engine would work without using a grid? I have a small grasp of what you're talking about but am not sure.
Quote this message in a reply
Member
Posts: 145
Joined: 2002.06
Post: #12
Something I've been waiting to see done is a 2d engine that doesn't use tiles, but instead uses OGL's ability to rotate, stretch, repeat, and blend textures to create a free-form world. Writing the editor and designing levels might take a little more work, but think of the flexibility you'd get.

"He who breaks a thing to find out what it is, has left the path of wisdom."
- Gandalf the Gray-Hat

Bring Alistair Cooke's America to DVD!
Quote this message in a reply
Member
Posts: 110
Joined: 2002.04
Post: #13
You can simply use a linked list of all the sprite in a level.
each sprite has a x, z coordinate.

Once per frame you make a smaller linked list of all the sprites in the active region...
AKA what you actually want to move or what the camera is looking at.

In PM this was a linked list for all the sprites in the level and a rectangle that was moved across the level.

A linked list of all the active sprites was built is the sprite had any part inside the rectangle.

People forget that computers are REALLY fast some times and doing things like sorting through 1000 sprites in real time might not be much of a hit at all.

PM BTW ran on 68K macs even....

- Mac Lead ZeniMax Online Studios
- Owner Plaid World Studios
- Resume: http://www.chrisdillman.com
Quote this message in a reply
Member
Posts: 446
Joined: 2002.09
Post: #14
Quote:Originally posted by inio
Something I've been waiting to see done is a 2d engine that doesn't use tiles, but instead uses OGL's ability to rotate, stretch, repeat, and blend textures to create a free-form world. Writing the editor and designing levels might take a little more work, but think of the flexibility you'd get.
Me too - My basic thinking is too approach it using common terrain texturing techniques. e.g. Use relatively low-res textures for overall colour (or even just vertex colours, or a combination of the two) then overlay tiled groups of detail textures...
Quote this message in a reply
KidTsunami
Unregistered
 
Post: #15
Chris, I get what you're saying, but what are the exact advantages of this. Is it just so you can have trees and other objects represented as sprites off of a grid pattern?

Inio and Frank, I understand how that would work to display like the ground or floor of a level, but what would be used to make walls, trees, and other assorted "objects" in the level. Would these just be added sprites? Please tell more, if I can get a good grasp of that I would really like to work on this engine. Cool
Quote this message in a reply
Post Reply