Forum   Search   Register   Log in SUBADAR FORUM
 

Splatter Mario

Pages: [1]
Programming Help
sprinkles

Chrome Whore
2009 Sep 6 • 2431
10 ₧
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.
    2010 Mar 30 at 18:12
superjer
superjer

2005 Mar 20 • 3742
For a 2D game on modern hardware you really don't need to worry about memory or CPU intensity. Focus on keeping the design simple instead.

You can always optimize it later but you can't always un-complicate it.

Does your idea involve not being able to go back to the left, like in Super Mario 1?
    2010 Mar 30 at 18:30
Rockbomb
Dog fucker

2009 Nov 13 • 1849
-190 ₧
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
    2010 Mar 30 at 18:41
sprinkles

Chrome Whore
2009 Sep 6 • 2431
10 ₧
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
the_cloud_system
polly pushy pants

2008 Aug 1 • 2788
-6 ₧
sprinkles said:
Gears of War




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.
    2010 Mar 30 at 19:08
sprinkles

Chrome Whore
2009 Sep 6 • 2431
10 ₧
the_cloud_system said:
sprinkles said:
Gears of War




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.
    2010 Mar 30 at 19:10
superjer
superjer

2005 Mar 20 • 3742
sprinkles said:
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.
    2010 Mar 30 at 21:26
sprinkles

Chrome Whore
2009 Sep 6 • 2431
10 ₧
superjer said:
sprinkles said:
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

Find the Hole II Participation Medal
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....
    2010 Mar 31 at 03:09
sprinkles

Chrome Whore
2009 Sep 6 • 2431
10 ₧
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.
    2010 Mar 31 at 07:08
superjer
superjer

2005 Mar 20 • 3742
sprinkles said:
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.

Or something similar.
    2010 Mar 31 at 13:41
sprinkles

Chrome Whore
2009 Sep 6 • 2431
10 ₧
That wouldn't move the screen position would it [like across the desktop]?
...then I got some ap, and shot a big ass lazar at everyone.
    2010 Mar 31 at 13:56
superjer
superjer

2005 Mar 20 • 3742
No. By screen.x I mean the in-game representation of the screen. Or the area in the game which is currently shown on the screen.

Anything that "area" contains or touches should then be drawn.

That way you can just move one object around and have it look like everything is moving.
    2010 Mar 31 at 14:26
sprinkles

Chrome Whore
2009 Sep 6 • 2431
10 ₧
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
superjer
superjer

2005 Mar 20 • 3742
The XNA Viewport is literally the window for your program.

I probably should'a been more clear but I mean a "viewing area" inside your game world that can move. So for example:

code
+----------------------+=====================+--------------------+
|                      |viewing area         |                    |
|                      |             +---+   |                    |
|                      |             |   |   +--->                |
|                      |             +---+   |      (stuff out    |
|     +---+            |            /        |            ahead)  |
|     |   |            |    visible block    |                    |
|     +---+            |      0              +--->                |
|    /                 |     /|\             |                    |
|   not visible block  |     /|              |                    |
+----------------------+=====================+--------------------+
                 /
              the entire level


The just draw the stuff that falls withing the "viewing area" as it moves. If that makes any sense.
    (Edited 2010 Apr 3 at 23:27)     2010 Mar 31 at 23:16
sprinkles

Chrome Whore
2009 Sep 6 • 2431
10 ₧
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.
    2010 Mar 31 at 23:31
sprinkles

Chrome Whore
2009 Sep 6 • 2431
10 ₧
Hmmm, I seem to have forgot that the draw method allows a vector2 or a rectangle. So all this need for rectangles....

Point = no need for rectangles.
...then I got some ap, and shot a big ass lazar at everyone.
    2010 Apr 5 at 07:11
Down Rodeo
Cap'n Moth of the Firehouse

Find the Hole II Participation Medal
2007 Oct 19 • 5258
57,583 ₧
    2010 Apr 6 at 07:04
sprinkles

Chrome Whore
2009 Sep 6 • 2431
10 ₧
Down Rodeo said:
Yer wot?



Is that your pirate persona?
...then I got some ap, and shot a big ass lazar at everyone.
    2010 Apr 16 at 17:45
Down Rodeo
Cap'n Moth of the Firehouse

Find the Hole II Participation Medal
2007 Oct 19 • 5258
57,583 ₧
    2010 Apr 18 at 02:47

Pages: [1]
Forum and design copyright © 2008-2010 SuperJer.com