Splatter Mario

Splatter Mario

sprinkles

Chrome Whore
2009 Sep 6 • 2547
10 ₧
Here is a demonstration of how I plan the tiles in each level to load and unload.

Sick vid



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.
 
 
 
2010 Mar 31 at 01:12 UTC
SuperJer
Websiteman

2005 Mar 21 • 6673
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 31 at 01:30 UTC
Rockbomb
Dog fucker (but in a good way now)

2009 Nov 14 • 2045
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 31 at 01:41 UTC
sprinkles

Chrome Whore
2009 Sep 6 • 2547
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?
 
 
 
2010 Mar 31 at 01:53 UTC — Ed. 2010 Mar 31 at 01:55 UTC
the_cloud_system
polly pushy pants

2008 Aug 1 • 3081
-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]
I drink to forget but I always remember.
 
 
 
2010 Mar 31 at 02:08 UTC
sprinkles

Chrome Whore
2009 Sep 6 • 2547
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.
 
 
 
2010 Mar 31 at 02:10 UTC
SuperJer
Websiteman

2005 Mar 21 • 6673
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 31 at 04:26 UTC
sprinkles

Chrome Whore
2009 Sep 6 • 2547
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.
 
 
 
2010 Mar 31 at 05:01 UTC — Ed. 2010 Mar 31 at 05:02 UTC
Down Rodeo
Cap'n Moth of the Firehouse

Find the Hole II Participation Medal
2007 Oct 19 • 5486
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
 
 
 
2010 Mar 31 at 10:09 UTC
sprinkles

Chrome Whore
2009 Sep 6 • 2547
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.
 
 
 
2010 Mar 31 at 14:08 UTC
SuperJer
Websiteman

2005 Mar 21 • 6673
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 20:41 UTC
sprinkles

Chrome Whore
2009 Sep 6 • 2547
10 ₧
That wouldn't move the screen position would it [like across the desktop]?
 
 
 
2010 Mar 31 at 20:56 UTC
SuperJer
Websiteman

2005 Mar 21 • 6673
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 21:26 UTC
sprinkles

Chrome Whore
2009 Sep 6 • 2547
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].
 
 
 
2010 Mar 31 at 21:30 UTC — Ed. 2010 Apr 1 at 05:52 UTC
SuperJer
Websiteman

2005 Mar 21 • 6673
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.
 
 
 
2010 Apr 1 at 06:16 UTC — Ed. 2010 Apr 4 at 06:27 UTC
sprinkles

Chrome Whore
2009 Sep 6 • 2547
10 ₧
I understand what you mean. I am jus' not sure on how to implement it. I will have to try it out.
 
 
 
2010 Apr 1 at 06:31 UTC
sprinkles

Chrome Whore
2009 Sep 6 • 2547
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.
 
 
 
2010 Apr 5 at 14:11 UTC
Down Rodeo
Cap'n Moth of the Firehouse

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

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



Is that your pirate persona?
 
 
 
2010 Apr 17 at 00:45 UTC
Down Rodeo
Cap'n Moth of the Firehouse

Find the Hole II Participation Medal
2007 Oct 19 • 5486
57,583 ₧
 
 
 
2010 Apr 18 at 09:47 UTC
Page [1]