Results 1 to 21 of 21

Thread: What is the best way to do backgrounds for games?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 1999
    Posts
    65
    I'm having trouble with this one. If I were to make an RPG, would I need a seperate form for each individual field? And should I use prerendered graphics in order to make the backgrounds, or should I just use some strange form of tiling?
    "I'm carrying a Geometry book, but I'm not in Geometry...it's crazy...crazy man!"

  2. #2
    Addicted Member Cbomb's Avatar
    Join Date
    Jul 1999
    Posts
    153

    Lightbulb Tiles

    Most RPG games use one file (-or maybe embed it in the EXE) filled with lots of tiles of diferent types. Like you have grass, trees, bushes, water, roads, and transitions. Then in your game you pick and choose tiles and build your map.

    KENNNY, Fox, Harry, this is where you guys come in and take over the conversation, (the resident game experts)

    Good Luck!

    ---5 mins later---

    Now I see that the answer I posted has no meaning in relation to you question...sorry. Lemme Try again.

    Field - Do you mean the tiles that fit into the screen (or form) at the same time?
    If so I think you maybe taking about scrolling... As the character walks around in this tiled world you constantly redraw the map with the new tiles in place...(am I making sence?)

    Example:
    The map is 100 by 100 tiles
    The "screen" in only 9 by 9 tiles.
    The character is always centered is the "screen." - FIG 1
    When the caracter move right the "screen" needs to refresh and show the new tile on the right and getrid of the old ones on the left - FIG 2

    Code:
          
    FIG 1     the dot = character
             ------------------\
             |  . |\_screen   | \
             |____|/          |  \
             |                |   \_map
             |                |   /
             |                |  /
             |                | /
             ------------------/
    
    
    FIG 2     
             ------------------\
             |  |  . |\_screen| \
             |  |____|/       |  \
             |                |   \_map
             |                |   /
             |                |  /
             |                | /
             ------------------/
    Ok..I hope this helps more...if at all

    PS: If this sound like I'm talking down to you, I apologize.

    [Edited by Cbomb on 04-17-2000 at 12:27 PM]
    Cbomb
    Techie

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 1999
    Posts
    65

    Hmm baba...

    Ok. If I do what you say, and insert new tiles on the right, and remove those from the left, wouldn't that be very choppy? I mean isn't there a way to make a smooth scrolling motion? Like in Zelda 3? Or is that just not possible with plain VB?
    "I'm carrying a Geometry book, but I'm not in Geometry...it's crazy...crazy man!"

  4. #4
    Hyperactive Member
    Join Date
    Jan 2000
    Posts
    355
    well yeah, you simply start drawing part-way along the tile.

    ie.

    your position in the map is 100,100
    the map is 1000*1000
    your tiles are say 64*64

    you do (100 mod 64) to get where to start drawing from on the leftmost tile onscreen: 36 . You have to make sure you draw from the right tile, too, but you can figure that out.
    It's not easy to explain, but good once you've got it working by the way, how are you doing your rendering?
    "native VB" - ie PaintPicture just isn't up to it, so dont use it
    buzzwords are the language of fools

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Oct 1999
    Posts
    65
    I want to use bitblt (I've gotten very accustomed to it), and I could simply change the x and y coordinates of my picture, but I can't blit into negative space. Otherwise it crashes. I'm totally at a loss of what to do, and I'm not going to make a game unless it can scroll. My god man, The Original Legend of Zelda could somewhat scroll, and it was on Nintendo.

    Man, I played that Paradox II game, and now my screen fonts have ceased to be softened. EEWW!!!!
    "I'm carrying a Geometry book, but I'm not in Geometry...it's crazy...crazy man!"

  6. #6
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Ok, Kenny already said the important things so... wanna download an example? You can find an older version of my engine here.

    (Hm.. I should take more time to discuss here )


  7. #7
    Hyperactive Member
    Join Date
    Jan 2000
    Posts
    355
    LOL - I didn't write Paradox II, it was written by someone I know And he's not in Cintel. Everyone I know thinks it's crap
    buzzwords are the language of fools

  8. #8
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Hehe, me a game expert? *Wishes he was*

    I can do the theory fine, but in practise I've done a little less than this guy has

    But thanks anyway. I hope to be an expert one day
    Harry.

    "From one thing, know ten thousand things."

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Oct 1999
    Posts
    65

    Kennny

    Meeesa Thinksa it isa crapsa toosa.
    "I'm carrying a Geometry book, but I'm not in Geometry...it's crazy...crazy man!"

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Oct 1999
    Posts
    65

    What in the hell is this?

    I don't understand any of that class crap. What is it, and why are you people all using it in your games? And I downloaded that demo you told me about, and... I don't understand the class thing. At all.
    "I'm carrying a Geometry book, but I'm not in Geometry...it's crazy...crazy man!"

  11. #11
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Well, do you know what a Type is?
    If not I'll short explain:



    Types
    ---
    A normal var can only contain 1 value... for example an integer can contain a number.
    Code:
    Dim A as Integer
    A = 10
    Well, but if we take something like a player, say the coordinates, you need more than 1 var:
    Code:
    Dim PlayerX as Long
    Dim PlayerY as Long
    Dim PlayerZ as Long
    That isn't very easy to handle, say you want to copy the coordinates anywhere... you would make something like this:
    Code:
    ObjectX = PlayerX
    ObjectY = PlayerY
    ObjectZ = PlayerZ
    So instead of this you can make a Type which contains these values:
    Code:
    Type tCoordinate
      X as Long
      Y as Long
      Z as Long
    End Type
    Well, now we can access the coordinates easier, like this:
    Code:
    Dim Player as tCoordinate
    
    'Set values
    Player.X = 10
    Player.Y = 20
    Player.Z = 1
    Also you can easy copy the values to another var of the same Type:
    Code:
    Dim Player as tCoordinate
    Dim Object as tCoordinate
    
    Player.X = 10
    Player.Y = 20
    Player.Z = 1
    
    Object = Player
    'Now Object.X is 10, .Y = 20 and .Z = 1
    Thats all.



    Classes
    ---
    As you know Types can only contain values, so if you want to make a function to set a value, say again the coordinates, you have to do something like this:
    Code:
    Public Sub SetPosition(iX as Long, iY as Long, iZ as Long)
      'If out of screen move back
      If iX < 0 Then: iX = 0
      If iY < 0 Then: iY = 0
      If iZ < 0 Then: iZ = 0
    
      Player.X = iX
      Player.Y = iY
      Player.Z = iZ
    End Sub
    Well, that's also a bit complicated because you always have to know which var you want to apply the values to. (Look at the example above, if you want to make the same function for enemies you have to copy it and replace Player with Enemy and also take another name like SetEnemyPos and so on...)

    The easier way to do this is to take a class coz classes can also contain functions. So your would directly call the class function like this:
    Code:
    'In class
    Dim X as Long
    Dim Y as Long
    Dim Z as Long
    
    Public Sub SetPosition(iX as Long, iY as Long, iZ as Long)
      'If out of screen move back
      If iX < 0 Then: iX = 0
      If iY < 0 Then: iY = 0
      If iZ < 0 Then: iZ = 0
    
      X = iX
      Y = iY
      Z = iZ
    End Sub
    
    'In form
    Dim Player as new cCoordinate
    Dim Enemy as new cCoordinate
    
    Player.SetPosition(10, 20, 1)
    Enemy.SetPosition(20, 12, 2)
    With this method you can declare anything as cCoordinate and then use it's SetPosition -function.

    Another difference is the declaration as you can see in the example. It's declared as New <classname> because else vb wouldn't find the object. You have to know that you can't copy Class values like Types, vb would make a pointer to the class you want to copy:
    Code:
    Dim Enemy as new cEnemy
    Dim Pointer as cEnemy
    
    Pointer = Enemy
    
    Pointer.SetPosition(10, 10, 20)
    'Now Enemy.X is 10, .Y = 10 and .Z = 20
    That means if you change a value of the pointer you will also change the value of the Player.



    End
    ---
    Well, hope it's not too much and hope also I tould everything about classes. If not feel free to post...

  12. #12
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Eh, it's my longest post yet

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Oct 1999
    Posts
    65

    Oh.

    But what about the camera and crap? How does that part of your project work?
    "I'm carrying a Geometry book, but I'm not in Geometry...it's crazy...crazy man!"

  14. #14
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Well, nearly the same what I told above...

    The camera-class contains 2 values, X and Y and one Function, LookAt. If you want to set the camera position you can directly call the function like
    Code:
    Camera.LookAt( -10, 100 )
    The function will determine the correct coordinates (ie. set -10 to 0) and then move the camera there. Easy, isn't it?



  15. #15

    Thread Starter
    Lively Member
    Join Date
    Oct 1999
    Posts
    65

    Alright.

    Fox,

    We've established how class modules work, now explain to me how you actually move and display the tiles. Mainly how you only display a part of one of them. That is the part of your program (the entire thing really) that I am confused about.

    Do you have ICQ or AIM? If so tell me your contact, you seem to know what you're talking about.
    "I'm carrying a Geometry book, but I'm not in Geometry...it's crazy...crazy man!"

  16. #16
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Did you ever click the 'profile' link just over my posts? Ther you'll find my ICQ number

    However, it's 46128728

    Will be much better if we can talk a bit faster coz this part is a bit complicated

  17. #17
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827

    Wink

    Hey Fox, you beat MY longest post. Mine was this long logic thing on the general forum,answering a maths question. Some kid couldn't be bothered to do his homework, so he got people on the forum to do it for him

    Anyway back to BitBlt..

    well yeah, you simply start drawing part-way along the tile.

    ie.

    your position in the map is 100,100
    the map is 1000*1000
    your tiles are say 64*64

    you do (100 mod 64) to get where to start drawing from on the leftmost tile onscreen: 36 . You have to make sure you draw from the right tile, too, but you can figure that out.
    Okay I'd just like to say that, as stated earlier, I haven't actually done this, but I'm pretty sure the theory is sound.

    Your basic unit in BitBlt is the pixel right? And you're getting the tile from a bitmap, which you then stick onto the front buffer. Okay, so you just, like, shift one edge of the little square of tile that you take a bit so that you cut the tile down in size, and take a rectangle. You are (I think) defining the coordinates of the tile you take in terms of pixels, so, if you move the view 9 pixels to the left, you paint all your tiles 9 pixels to the right. That means the tiles on the right get 9 pixels shorter, and you add 9 pixels of a row of tiles on the left. This making sense? You just change the coordinates (in this case so that your x value is shifted by 9) that define where each tile is painted, and how large the tiles on the far left and right are. It's err.. kinda simple when you think about it. Well it is if I'm right anyway

    I haven't used BitBlt in a while, so I might have got it wrong. Anyway, Fox will post one of his usual well-explained replies soon and so you can just ignore me then
    Harry.

    "From one thing, know ten thousand things."

  18. #18

    Thread Starter
    Lively Member
    Join Date
    Oct 1999
    Posts
    65

    Okay I don't know if this has any relevance to what you said but:

    I can easily shift the tiles towards the right and bottom of the screen, but if I try to blit into negative space the program crashes. Any way I can fix this?

    Oh Fox, I'm awaiting authorization. So if you're online reading this, go to ICQ and let me through.
    "I'm carrying a Geometry book, but I'm not in Geometry...it's crazy...crazy man!"

  19. #19
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Well my advice for Blitting into negative space is don't do it

    I guess you mean you're trying to paint to coordinates that are outside the image box or picture box or whatever (can't remember which). The idea is you move the coordinates you're taking from and change the dimensions of the edge tiles so that you are painting to the edge of the box, not outside it.

    Tell me if I have got completely the wrong end of the stick as I am saying all this purely based on what I have seen in some of Fox's work before and from my limited experience with BitBlt.
    Harry.

    "From one thing, know ten thousand things."

  20. #20

    Thread Starter
    Lively Member
    Join Date
    Oct 1999
    Posts
    65

    Cool Thanks Harry, Fox, and Kennny.

    You guys all helped me understand this junk, I guess before I was too scared to experiment with my ideas, or something. The whole thing I was having a problem with was summed up in Harry's last post, Fox helped me on a chat, and Kennny, well I'm making graphics for his game (), which is fun for me.

    Anyways thanks everyone, I'm that much more able to make games now.
    "I'm carrying a Geometry book, but I'm not in Geometry...it's crazy...crazy man!"

  21. #21
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088

    Wink

    No problem, just send us a free copy of your game *g*

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width