Like Tree3Likes
  • 1 Post By nvoigt
  • 1 Post By Lesshardtofind
  • 1 Post By VirtualAce

Backgrounds And some questions about SuperMario

This is a discussion on Backgrounds And some questions about SuperMario within the Game Programming forums, part of the General Programming Boards category; Huy guys! i am learning XNA and i need some helps about background in my Game (SuperMario); so : 1. ...

  1. #1
    Registered User
    Join Date
    Oct 2012
    Posts
    10

    Backgrounds And some questions about SuperMario

    Huy guys!
    i am learning XNA and i need some helps about background in my Game (SuperMario);
    so :
    1. i already have searched internet for founding a good background for my game , and until now i havent find a good background , can you help me about this (give me some links ) ?

    2. after choosing bakground and i make the structs ... i wanna show the game in 800*600 , (assume my background is 1920*600 ) how can i show part of map in any motion of Mario?? i mean i wanna scroll the background

    Thank you,
    Last edited by Seniorija; 01-24-2013 at 02:05 AM.

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    OpenGameArt.org has a lot of free graphics, maybe you can find a nice background there. Check the license agrrements, most are free to use, some require you to mention them in the credits if you use their pictures. That's only fair.
    Seniorija likes this.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Registered User
    Join Date
    Oct 2012
    Posts
    10
    nvoigt : Thank you for your reply ... i chose a nice background for my game ... (danke )

  4. #4
    Bored Programmer
    Join Date
    Jul 2009
    Location
    Tomball, TX
    Posts
    407
    As for your second question are you using Game Studio? It's been a while since I used XNA and C# but I remember there are multiple overloaded versions of the render sprite function (I can't recall it by name) but one of the overloads allows you to set the coordinates of the source rectangle. That will be the one that you want to use so that you can scroll through the map based on the player's location on the screen.

  5. #5
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    You can scroll the background any way you want but I do not recommend attempting to scroll a very large image. You will want to use a tile-based approach in rendering. My current tile renderer only renders what is visible and I have tested it with maps as large as 4096x4096. The only thing it does not do well is play nice with the GC. When the map goes out of scope the GC has a rough time cleaning it all up.

    What you want to do is figure out where you are in the tile map based on the current X and Y scroll. Once you figure that out you want to start at the top left and move to bottom right horizontally or vertically. Vertically is a bit quicker but the algorithm is a little different.

    I will describe the horizontal algorithm. First save your starting offset. Now the general idea is to move across the screen and increment the map offset and current X and Y tile position. Draw the tile at the current offset and increment X by tilewidth. The tile is determined by the ID in the map. The ID corresponds to a lookup in a tile collection. When you reach the right side of the screen, add the width of the map to your starting offset, increment Y by the height of the tile and repeat the process. Repeat this until the the y coordinate reaches the bottom of the screen or you are at the edge of the map...whichever comes first. Because you have taken into account the current offset in the map based on the scroll values all you need to do to scroll the map is increment or decrement the X and Y scroll values. Make sure to account for the edges of the map so you do not blow the bounds of your tile map array and you should have a rudimentary tile renderer. This will only draw the current visible portion of the map based on the X and Y scroll values ensuring you can use very large maps.
    Seniorija likes this.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. packaging images /backgrounds
    By rogster001 in forum C++ Programming
    Replies: 2
    Last Post: 11-11-2009, 08:01 AM
  2. Scrolling backgrounds
    By sand_man in forum Game Programming
    Replies: 13
    Last Post: 11-16-2005, 04:47 AM
  3. DrawText and backgrounds c++
    By AtomRiot in forum Windows Programming
    Replies: 1
    Last Post: 01-04-2003, 02:10 AM
  4. Bitmaps as backgrounds
    By Dissata in forum Windows Programming
    Replies: 5
    Last Post: 01-01-2003, 10:13 AM
  5. Window Backgrounds--I'm sick of brushes
    By Xterria in forum Windows Programming
    Replies: 11
    Last Post: 11-04-2001, 05:59 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21