Here is a demonstration of how I plan the tiles in each level to load and unload.
I plan to draw every rectangle in the level at load. Then programmatic decrease the x coordinate. When the rectangle reaches the right edge of the screen the sprite will be drawn inside it. It continues to move until it is no longer in the viewport then disposes of it.
This is the easiest way, and least memory intensive way I could think of how to do it. Any suggestions?
P.S.
I was going to use an array of rectangles, and when the got off screen reuse them, but that would limit the amount of rectangles allowed on screen. Or it would be too big and take up more resources.
...then I got some ap, and shot a big ass lazar at everyone.
God I hope this isn't like one of those levels where it auto-scrolls and if you stop it pushes you and you either get crushed or fall off a cliff... those levels always pissed me off
Once you get 2/3 of the screen it will start to scroll, but if you're idle it will not. And, I don't plan for them to be able to go 'back.' My main concern is that this isn't Counter Strike or Gears of War, so I figured people would like multi-task with it. That is why I wanted it to be [somewhat] light on resources.
superjer said:
Focus on keeping the design simple instead.
How'd you suppose I make it simple? With the array idea?
...then I got some ap, and shot a big ass lazar at everyone.
(Edited 2010 Mar 30 at 18:55)
2010 Mar 30 at 18:53
Damon Baird: Corpser!
Marcus Fenix: It's pulling back.
Damon Baird: Yah, it's gonna wait. Save us for later.
[ominously]
Damon Baird: Like a snack.
Marcus Fenix: Bullshit.
Damon Baird: You think I'm kidding?
Marcus Fenix: I think you're bat-shit crazy. That's what I think.
Augustus Cole: Aww, ain't that cute.
Dominic Santiago: Like two assholes on their first date.
Augustus Cole: [laughs]
moo moo moo, moo.
Damon Baird: Corpser!
Marcus Fenix: It's pulling back.
Damon Baird: Yah, it's gonna wait. Save us for later.
[ominously]
Damon Baird: Like a snack.
Marcus Fenix: Bullshit.
Damon Baird: You think I'm kidding?
Marcus Fenix: I think you're bat-shit crazy. That's what I think.
Augustus Cole: Aww, ain't that cute.
Dominic Santiago: Like two assholes on their first date.
Augustus Cole: [laughs]
Cole is def my favourite.
...then I got some ap, and shot a big ass lazar at everyone.
That is why I wanted it to be [somewhat] light on resources.
It's 2D. It will be light on resources until you add some crazy post-processing graphical effects. There's really no other option.
sprinkles said:
How'd you suppose I make it simple? With the array idea?
Yeah arrays are pretty simple. What are you making this in again? There might be a "collection" -like data structure better suited to sticking all these objects in. You should be able to add and remove them easily, ideally.
Or just load them all into one big array when the map loads.
That is why I wanted it to be [somewhat] light on resources.
It's 2D. It will be light on resources until you add some crazy post-processing graphical effects. There's really no other option.
sprinkles said:
How'd you suppose I make it simple? With the array idea?
Yeah arrays are pretty simple. What are you making this in again? There might be a "collection" -like data structure better suited to sticking all these objects in. You should be able to add and remove them easily, ideally.
Or just load them all into one big array when the map loads.
The problem is I need to know all the tiles' positions before hand. So I would need a multidimensional array of the positions, then an array of rectangles to draw them. And I really hate arrays.
Hmm...I guess that wouldn't be too hard.
Here's an idea:
Say I do the same as above but with a multidimensional array. I read from the level file the positions of the tiles (which are limited to 64x64, so I only need x and y), then slam them into the array. Then when needed I add a value to each x of the array to simulate movement. Check to see if the x is at the edge of the screen, if it is use a recycled rectangle (from an array of rectangles.), and throw a sprite on it. Check to see if the rectangle is still in the viewport, and if it is not then recycle the rectangle and sprite.
...then I got some ap, and shot a big ass lazar at everyone.
(Edited 2010 Mar 30 at 22:02)
2010 Mar 30 at 22:01
Down Rodeo Cap'n Moth of the Firehouse
2007 Oct 19 • 5258
57,583 ₧
Sounds like you need classes son!
Seriously, that would simplify everything SO MUCH. Make yourself some kind of Sprite class, the extend it for the player character and so on. Does C# have multiple inheritance? Some half-remembered thought says "no!" but I don't trust it Everyone stares when you walk in the room, they stare when you go....
I know I need classes. And no, you cannot inherit from more than one class. I jus' wanted to know if that idea sounded on cue.
...then I got some ap, and shot a big ass lazar at everyone.
Here's an idea:
Say I do the same as above but with a multidimensional array. I read from the level file the positions of the tiles (which are limited to 64x64, so I only need x and y), then slam them into the array. Then when needed I add a value to each x of the array to simulate movement. Check to see if the x is at the edge of the screen, if it is use a recycled rectangle (from an array of rectangles.), and throw a sprite on it. Check to see if the rectangle is still in the viewport, and if it is not then recycle the rectangle and sprite.
You've got the right idea. I think it would be easier to move the screen though, rather than all the blocks. Just have the screen.x go from 0 up and draw the blocks only if block.x - screen.x < screen.width.
In that case I will jus' draw all the sprites....no that would increase load time. Eh, we'll see. I also have to see if I can do that with the viewport (in XNA viewport is equivalent to screen) [that is move it I know it has an x value].
...then I got some ap, and shot a big ass lazar at everyone.
(Edited 2010 Mar 31 at 22:52)
2010 Mar 31 at 14:30
I understand what you mean. I am jus' not sure on how to implement it. I will have to try it out.
...then I got some ap, and shot a big ass lazar at everyone.