Side scroller...mabye?
Author |
Message |
rcbhs
|
Posted: Thu Dec 03, 2009 8:50 am Post subject: Side scroller...mabye? |
|
|
Ok so year end projects starting and we are contemplating doing a side scroller. Anyways, I have a slight idea how we could spawn the levels and have the scroll if the levels were random, however, we don't want random, we want premade levels that we built to specifics, but I have no idea how to do that.
I'm wondering if somebody can enlighten me as to how we might make it possible to scroll through a level sidescroller like. If we can't get a good idea of how to do it (I'm not asking for code or anything just an explination on how to do it) then we won't be making a sidescroller.
Anyways, thanks in advance. |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
DemonWasp
|
Posted: Thu Dec 03, 2009 11:37 am Post subject: RE:Side scroller...mabye? |
|
|
Think of the Turing window as a literal "window" into the world of your side-scroller. You are looking through this window to see a portion of the game world. I will assume that everything in your game world has a position (x,y).
Because you want to look around, you will need your window to also have a position (wx,wy). When you draw things, the position of that thing in the window will be (x-wx,y-wy), which accounts for the position of the window relative to the position of the object. This is the location at which you would draw the object (picture, box, oval, whatever).
You would update the window's position based on the position of your character. In general, you would tend to have your character near the middle of the screen. Since you know the width of the screen and the position of your character, doing so should be simple enough. |
|
|
|
|
 |
Zren

|
Posted: Thu Dec 03, 2009 12:10 pm Post subject: Re: Side scroller...mabye? |
|
|
I can think of two ways, but both involve some file IO. So how you structure it is up to you. These are just some of the concept I've seen, and there's probably more out there.
Images
This way is pretty easy when it comes to modifying the layout of the map. It's based on either having specific colours to represent specific objects like walls, traps etc. You can also have a different image to use for the walls (black & white).
The downside is probably that you'd have to blit (draw) a massive image every single frame (unless you clip it).
Tiles
Ever played Heli Attack 3? That's basically how it'll look. You get a few images to represent a ton of different objects (platforms).
The downside to this approach is probably wanting to make a level editor to edit the tiles.
NPC/Monsters
Ideally, you could make each NPC have their own text file in a folder named "npc", and use the Dir module to find each text file and load it into your Monster class. Each NPC would get an index.
You would then put calls to those monsters in your map files, with their coordinates and possibly even individual characteristics.
Triggers & Boss Mode
I don't know much about these. Never really used them before. |
|
|
|
|
 |
rcbhs
|
Posted: Mon Dec 07, 2009 8:50 am Post subject: Re: RE:Side scroller...mabye? |
|
|
DemonWasp @ Thu Dec 03, 2009 11:37 am wrote: Think of the Turing window as a literal "window" into the world of your side-scroller. You are looking through this window to see a portion of the game world. I will assume that everything in your game world has a position (x,y).
Because you want to look around, you will need your window to also have a position (wx,wy). When you draw things, the position of that thing in the window will be (x-wx,y-wy), which accounts for the position of the window relative to the position of the object. This is the location at which you would draw the object (picture, box, oval, whatever).
You would update the window's position based on the position of your character. In general, you would tend to have your character near the middle of the screen. Since you know the width of the screen and the position of your character, doing so should be simple enough.
I may be reading this wrong but I don't think you fully understand our problem. Our problem is that we have a picture that is 3200 pixels in width and we are trying to scroll it back off the screen as we go, however, we don't know how to go about doing that. This is our first shot at it (which isin't working at all)
code: | setscreen ("graphics:800;600")
var key : string (1)
var screenPosition : int := 0
var background : int
background := Pic.FileNew ("back.bmp")
var backWindow : int := Window.Open ("graphics:3200;600")
Window.SetActive (backWindow)
Pic.Draw (background, 0, 0, picCopy)
Window.Hide (backWindow)
Window.SetActive (-1)
%Window
loop
getch (key)
if key = KEY_RIGHT_ARROW then
screenPosition := screenPosition - 10
Window.SetActive (backWindow)
background := Pic.New (screenPosition, 0, screenPosition + 799, 599)
Window.SetActive (-1)
Window.Show (-1)
Pic.Draw (background, screenPosition, 0, picCopy)
Pic.Free (background)
end if
end loop |
|
|
|
|
|
 |
TheGuardian001
|
Posted: Mon Dec 07, 2009 9:18 am Post subject: Re: Side scroller...mabye? |
|
|
DemonWasp seems to have exactly what you want.
Lets assume that your player will always be centered on the window (They don't have to be, but it's simpler).
Now, lets say that X and Y represent the coordinates of the bottom left corner of the image, which is where the image will be drawn. Like DemonWasp said, since your window shouldn't be anywhere near 3200 pixels wide, this means that only part of your image will be drawn. To control the part of the image that gets drawn, you simply change the X and Y values based on where the player moves. So if your player moves to the right, X should decrease(moving the image left), and if the player moves left, X should increase (moving the image left.)
The same concept applies for everything else in the game world. If the player walks right, it will have the same effect as everything else in the world moving left.
So start off with the image at 0,0, and then literally just move it left by decreasing the X coordinate you draw it at. |
|
|
|
|
 |
DemonWasp
|
Posted: Mon Dec 07, 2009 10:10 am Post subject: RE:Side scroller...mabye? |
|
|
I'm pretty sure you're just not understanding what I'm trying to say. Not sure whether that's my poor wording or you being unclear about the problem.
Your attempt won't work because you're drawing at (screenPosition, 0). You should probably be drawing at (0,0), as you have already factored screenPosition in while getting the "background" picture from the hidden window.
That said, there's a simpler way: draw your background at (-screenPosition, 0) to the main screen and skip the hidden window entirely. |
|
|
|
|
 |
|
|