GPWiki.org
GPWiki.org
It is currently Tue May 21, 2013 7:54 am

All times are UTC




Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Fri Oct 14, 2011 5:17 pm 
Super-dooper pooper scooper
User avatar

Joined: Tue Oct 11, 2011 8:08 pm
Posts: 170
So for my first semi-biggish project, I started a breakout clone with XNA. Still no collision detection, settings, good texture, etc... I used a tutorial to get the basic blocks and paddle and ball up, and am planning on doing everything else myself.

1. How would you draw a tiled background texture, and then draw the other textures over that.

2. When I run it in full screen there is a border to the right. Everything still works, but it looks bad. :confused
Image

3. When the player's lives (as seen above) reaches 0, how do you either clear the screen and give a

"Would you like to play again Y/N" message OR do a
Code:
messagebox.show("would you like to play again?","Game Over"); //etc

And yes, I am using XNA GPA's v4 tutorial...


Top
 Profile  
 
PostPosted: Fri Oct 14, 2011 5:36 pm 
Harmlessness does no harm
User avatar

Joined: Tue Sep 14, 2004 8:37 pm
Posts: 3807
Location: Ferriday, LA, US
1.a. Drawing a tiled background basically involves using a for-loop to draw an image several times in different places, making a "single" image. There are lots of tutorials on tiling (including a couple here on the Wiki), so I won't go into that too much here.

1.b. You can draw your background first, and after that draw everything that should appear above, and that's all it takes. If that doesn't work for some reason, make sure you're drawing everything in the correct Z Order (see the MSDN for more details on drawing sprites with Z ordering).

2. This is most likely due to your window having a different resolution/aspect-ratio from your screen. One approach to the issue would be to draw borders around the play area, and make sure that the play area itself is always centered on the screen. Another would be to make sure that windowed mode and fullscreen mode use compatible aspect ratios.

3. One way to do this would simply be to draw something that covers the screen (a solid color, or maybe even a tiled background), and then use text to display your message. Then you can draw two "buttons" (either with code or with actual images) that the user can click on to decide what to do. Simply check for the mouse's position to see which button (if any) it is over on a click.

If you need any more help or explanation on anything, let us know! :)

_________________
What most people don't understand about "enlightenment" is that it is not an end-goal; but where you find yourself just before taking a new "first step."


Top
 Profile  
 
PostPosted: Fri Oct 14, 2011 9:36 pm 
Hi.

I recently was looking around for a 'how do i make a tiled background' for my own game, I thought there might have been some XNA command to do it.. i couldn't find any satisfactory answer, so I ended up just calling the Spritebatch.Draw method a few times. I dont like doing it that way, but what can ya do?

My texture is 600x600, so I did this.

SpriteBatch.Draw(myTexture, 0,0, blah blah blah)
SpriteBatch.Draw(myTexture, 600, 0, blah blah)
SpriteBatch.Draw(myTexture, 1200, 0, blah blah)

etc etc.

I suppose I couldve added a loop with some math to do this automatically, but whatever. I didn't. lol.

What I'm looking for now is how to do *scrolling* backgrounds. It's one of those things that my current engine could do manually, but I'm looking for a more elegant way to do it.

Anyway. Just my 0.02.

-Jimbo


Top
  
 
PostPosted: Fri Oct 14, 2011 9:41 pm 
Grand Optimizer
User avatar

Joined: Mon Jan 17, 2005 6:01 pm
Posts: 352
Location: Canada
Yay im logged in.

To answer the other question, about layering, the SpriteBatch.Draw method has a "Layer Depth" parameter, which takes a float value. The *HIGHER* you set that float value, the LOWER, or DEEPER that texture will be drawn. For example, 0.0 is the "top" layer. So, a car drawn at layer depth 0.5 will be drawn ON TOP of grass with a layer depth of 0.6.

_________________
"None are more hopelessly enslaved than those who falsely believe they are free."
"It is no measure of health to be well adjusted to a profoundly sick society."
"Hope is the first step on the road to dissapointment." -Jonah Orion
http://tankzgame.blogspot.com


Top
 Profile  
 
PostPosted: Fri Oct 14, 2011 9:50 pm 
Harmlessness does no harm
User avatar

Joined: Tue Sep 14, 2004 8:37 pm
Posts: 3807
Location: Ferriday, LA, US
Long time no see, Jimbo! (This is theraje, if you remember me from way back when.)

JimboNotLoggedIn wrote:
Oh hey, on an unrelated note, does the old "Lucky" still visit these forums? I miss that guy.


Lucky hasn't been around much at all since the site started to take off. In fact, GPWiki.org is now under new management as of earlier this year -- Codehead is running things now. :)

_________________
What most people don't understand about "enlightenment" is that it is not an end-goal; but where you find yourself just before taking a new "first step."


Top
 Profile  
 
PostPosted: Fri Oct 14, 2011 9:53 pm 
Grand Optimizer
User avatar

Joined: Mon Jan 17, 2005 6:01 pm
Posts: 352
Location: Canada
that sucks. That guy was game programming knowledge in a can.

Without his pro-written VB-Game tutorials, I probably would've given up programming a long time ago.

I'm still a programming newb, but I've come a long way.. thanks in no small part to this very site and the people who post here.

_________________
"None are more hopelessly enslaved than those who falsely believe they are free."
"It is no measure of health to be well adjusted to a profoundly sick society."
"Hope is the first step on the road to dissapointment." -Jonah Orion
http://tankzgame.blogspot.com


Top
 Profile  
 
PostPosted: Tue Oct 18, 2011 6:02 pm 
Super-dooper pooper scooper
User avatar

Joined: Tue Oct 11, 2011 8:08 pm
Posts: 170
rotInMilc wrote:
2. This is most likely due to your window having a different resolution/aspect-ratio from your screen. One approach to the issue would be to draw borders around the play area, and make sure that the play area itself is always centered on the screen. Another would be to make sure that windowed mode and fullscreen mode use compatible aspect ratios.


Erm... Clarification on the second question please. How would I adjust the aspect ration or do whatever to make the two compatible. (BTW I got the tiled thingy sorted out, thanks...)

Off Topic: Also, how much more difficult is it to make Isometric games with XNA. I know there's more graphic work, but is there necessarily more coding?


Top
 Profile  
 
PostPosted: Tue Oct 18, 2011 6:39 pm 
King Code Monkey
User avatar

Joined: Wed Sep 01, 2004 3:05 pm
Posts: 11182
Location: Abingdon, MD
Lexusjjss wrote:
Off Topic: Also, how much more difficult is it to make Isometric games with XNA. I know there's more graphic work, but is there necessarily more coding?

Not really. There's a bit more work in calculating where to draw things, but overall drawing graphics is drawing graphics.

Can you post the code that you're using to set up full screen mode?

_________________
Bored? Head on over to my blog and see what I'm up to.

Microsoft XNA MVP


Top
 Profile  
 
PostPosted: Tue Oct 18, 2011 10:51 pm 
Harmlessness does no harm
User avatar

Joined: Tue Sep 14, 2004 8:37 pm
Posts: 3807
Location: Ferriday, LA, US
Lexusjjss wrote:
Erm... Clarification on the second question please. How would I adjust the aspect ration or do whatever to make the two compatible.

The aspect ratio is the difference between the width and height of your window or screen. Most likely, you're using a 4:3 ratio for the width:height of your game surface, while your screen has a native resolution that is 16:9 or 16:10 (both of which are considered widescreen).

The easiest way to fix the problem would be to draw the game as you already are, but center the play area (take the screen width, subtract the play-area width from that, and then halve the result) and draw some sort of border in the 'empty' space.

_________________
What most people don't understand about "enlightenment" is that it is not an end-goal; but where you find yourself just before taking a new "first step."


Top
 Profile  
 
PostPosted: Fri Oct 28, 2011 11:05 pm 
Seems to me the SCREENWIDTH/SCREENHEIGHT is inconsistent with how many blocks you've drawn, vs the size of the blocks.

If the screenwidth/back buffer width. are set to a size that isn't a multiple of the width of your blocks, then it wont work properly.

Example: 800x600... thats 800 x 600 pixels. 800 wide.

Youve got 10 blocks. So if you made the block sprite 80 pixels wide, it'd work fine. and so on.


Top
  
 
PostPosted: Thu Nov 10, 2011 1:29 am 
Super-dooper pooper scooper
User avatar

Joined: Tue Oct 11, 2011 8:08 pm
Posts: 170
Okay, weird brick problem solved, paddle collision detection math added, game state stuff almost done, music and sound operational.
The problem with that brick thing was that I was using NO code to set up anything. Just using the brick texture width as a guideline, not the screen size. :doh

So how would you use a SortedList to access a file, retrieve high scores, SAVE highscores, and post them to the main menu?
Also, just so I know how I'm doing, how long would it take you guys to, from scratch, make a breakout clone?


Top
 Profile  
 
PostPosted: Thu Nov 10, 2011 1:52 am 
King Code Monkey
User avatar

Joined: Wed Sep 01, 2004 3:05 pm
Posts: 11182
Location: Abingdon, MD
Lexusjjss wrote:
Also, just so I know how I'm doing, how long would it take you guys to, from scratch, make a breakout clone?


I could probably have one done in about an hour. :) I've been doing this for a good while though, so that's probably not typical.


Lexusjjss wrote:
So how would you use a SortedList to access a file, retrieve high scores, SAVE highscores, and post them to the main menu?

You wouldn't use a sorted list. You might look at this and the links at the bottom of that page.

_________________
Bored? Head on over to my blog and see what I'm up to.

Microsoft XNA MVP


Top
 Profile  
 
PostPosted: Thu Nov 10, 2011 2:28 am 
Super-dooper pooper scooper
User avatar

Joined: Tue Oct 11, 2011 8:08 pm
Posts: 170
I know mostly how the StreamReader and StreamWriter stuff works. (I made a replacement for notepad in a couple of days)
What I mean is what is the best way to do the saving and loading of highscores? I was thinking a sorted collection class with a loop to access 10 high score fields, but I don't really know how to do that. :rolleyes


Top
 Profile  
 
PostPosted: Thu Nov 10, 2011 1:19 pm 
King Code Monkey
User avatar

Joined: Wed Sep 01, 2004 3:05 pm
Posts: 11182
Location: Abingdon, MD
You might take a look at this.

_________________
Bored? Head on over to my blog and see what I'm up to.

Microsoft XNA MVP


Top
 Profile  
 
PostPosted: Thu Nov 10, 2011 11:23 pm 
Super-dooper pooper scooper
User avatar

Joined: Tue Oct 11, 2011 8:08 pm
Posts: 170
Also, how to add animations (explosion when ball goes off the screen), and how to make a fade-to-black if the player dies?
Small words please.

Machaira: AN HOUR! :x
Then what about a fully configurable breakout clone, with sound, music, menus, special bricks, highscores and a level editor? :evil


Top
 Profile  
 
PostPosted: Fri Nov 11, 2011 10:19 am 
Dexterous Droid
User avatar

Joined: Wed Aug 18, 2004 7:40 pm
Posts: 3735
Location: South Africa
Lexusjjss wrote:
Machaira: AN HOUR! :x
Then what about a fully configurable breakout clone, with sound, music, menus, special bricks, highscores and a level editor? :evil

Oh, only that? In that case, it would take him half an hour ;)

_________________
Whatever the mind can conceive and believe, it can achieve


Top
 Profile  
 
PostPosted: Fri Nov 11, 2011 11:23 am 
Corpse Bride
User avatar

Joined: Tue Jul 01, 2008 11:44 pm
Posts: 2216
Location: England
Lexusjjss wrote:
Machaira: AN HOUR! :x


Join Glorious Trainwrecks, and enter competitions to make games from scratch (using no preexisting code) in 2 hours..
http://www.glorioustrainwrecks.com/forum

Join 0hgame jam and enter competitions to make games from scratch (no preexisting code) in 0 hours..
http://0hgame.eu/

I enjoy taking part in these things, and I can be quite productive under such pressure. :yeah

_________________
I ain't pushing no moon buttons.


Top
 Profile  
 
PostPosted: Fri Nov 11, 2011 12:52 pm 
King Code Monkey
User avatar

Joined: Wed Sep 01, 2004 3:05 pm
Posts: 11182
Location: Abingdon, MD
IGTHORN wrote:
Lexusjjss wrote:
Machaira: AN HOUR! :x
Then what about a fully configurable breakout clone, with sound, music, menus, special bricks, highscores and a level editor? :evil

Oh, only that? In that case, it would take him half an hour ;)

heh, nah, it would take about a day. 10 hours maybe to make it really good.

_________________
Bored? Head on over to my blog and see what I'm up to.

Microsoft XNA MVP


Top
 Profile  
 
PostPosted: Fri Nov 11, 2011 6:48 pm 
Super-dooper pooper scooper
User avatar

Joined: Tue Oct 11, 2011 8:08 pm
Posts: 170
OK, good, I've only been working on this for 10 hrs total (schools keeping me busy enough), and I'm about 1/3 of the way done. I only get to code for 2-4 hours a day.

So animations in XNA? Tutorials, code samples?


Top
 Profile  
 
PostPosted: Fri Nov 11, 2011 7:18 pm 
King Code Monkey
User avatar

Joined: Wed Sep 01, 2004 3:05 pm
Posts: 11182
Location: Abingdon, MD
What kind of animations do you need for a Breakout clone?

_________________
Bored? Head on over to my blog and see what I'm up to.

Microsoft XNA MVP


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group