Results 1 to 19 of 19

Thread: Best way to do a tile engine

  1. #1

    Thread Starter
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    OpenGL?



    But seriously, you could try to do it with BitBlt or something, but I don't think it's fast enough for fullscreen tiled games. If you really want fast (and I know you don't want to hear this), try learning DirectX. For 2D, I still recommend DX7. It's a bit though when starting, but once you get to know it a little better, it's easy (and fast ). In case you haven't heard of it yet, go to http://www.vbexplorer.com/directx4vb/, it's a great source of information.
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  2. #2
    Member
    Join Date
    Sep 2001
    Location
    Quebec, Canada
    Posts
    43
    All right, I'll check into that website and give a try to Directx...

    And I have a question about BitBlt, too. I began toying with it a few days ago, and it does the job all right, with the mask and everything... But when I tried, the source picture needed to be on the screen, or else the destination pic would show just like the original... Can't I make that original invisible? There has to be a way...
    - Dr. Cossack

    Interordi.com: Internet tools, programming, games, and more!

  3. #3

    Thread Starter
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    Did you set AutoRedraw on the PictureBox to true? I think that solves the problem...
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Store the scroll offset vector,
    in redraw routine inlcude the scroll offset, by in nested loops increment tile and screen offsets starting from scroll offset ending at scrolloffset + screen offset (assuming scrolloffset is in pixels, otherwyas it's tileoffset)after inner loop, reset inner loop increment to scrolloffset component
    in the input routine (mouse or keyboard) add an offset to the scroll vector.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5
    Member
    Join Date
    Sep 2001
    Location
    Quebec, Canada
    Posts
    43

    Thumbs up

    PsychoMark: Thanks, that did the trick. I completely forgot about that option...

    kedaman: Err, what are you talking about? I don't understand...
    - Dr. Cossack

    Interordi.com: Internet tools, programming, games, and more!

  6. #6
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Err, what are you talking about? I don't understand...
    It's kedaman what do you expect?

    But if you looked at it and read it through maybe once or twice, he's giving you an alternate solution for your problem (I think...)!
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    alternative?

    I thought you wanted some fundamentals of scrolling...
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  8. #8
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    All right, I had a simple tile engine in DX running at about 60 FPS, and after using this technique, it ran at 800 FPS!!!

    VB Code:
    1. Dim TileX as Long, TileY as Long
    2.  
    3. TileX = 0
    4. TileY = 0
    5.  
    6. For X = 0 To 19
    7.   For Y = 0 To 14
    8.     'Here, the coordinates where you should blt to are NOT X*TileWidth and Y*TileHeight, but TileX and TileY. In this example, you're avoiding 600 multiplications with additions so it's a LOT faster :)
    9.  
    10.     TileY = TileY + TileHeight
    11.   Next Y
    12.  
    13.   TileX = TileX + TileWidth
    14.   TileY = 0
    15. Next X

    Try it, maybe the FPS won't be the same, but it will at least be 1000% faster than the old method
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  9. #9
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Originally posted by Jotaf98
    All right, I had a simple tile engine in DX running at about 60 FPS, and after using this technique, it ran at 800 FPS!!!

    VB Code:
    1. Dim TileX as Long, TileY as Long
    2.  
    3. TileX = 0
    4. TileY = 0
    5.  
    6. For X = 0 To 19
    7.   For Y = 0 To 14
    8.     'Here, the coordinates where you should blt to are NOT X*TileWidth and Y*TileHeight, but TileX and TileY. In this example, you're avoiding 600 multiplications with additions so it's a LOT faster :)
    9.  
    10.     TileY = TileY + TileHeight
    11.   Next Y
    12.  
    13.   TileX = TileX + TileWidth
    14.   TileY = 0
    15. Next X

    Try it, maybe the FPS won't be the same, but it will at least be 1000% faster than the old method
    ewww
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  10. #10
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Is it sarcasm I'm smelling?...
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  11. #11
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Originally posted by Jotaf98
    Is it sarcasm I'm smelling?...
    of course but never mind, there was a time when i did it that way too, but that was way back in the 90's
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  12. #12
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457


    What do you mean? How do you make it now?...
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  13. #13
    Member
    Join Date
    Sep 2001
    Location
    Quebec, Canada
    Posts
    43
    Hey, I'm still at that level of programming, okay?

    Jotaf98, can you just give me a sample of the BitBlt line that goes with that code? I want to make sure I'm not doing something bad :P
    - Dr. Cossack

    Interordi.com: Internet tools, programming, games, and more!

  14. #14
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Just call me Jotaf, ok?

    (I haven't changed it because they won't let me do that )

    If you already have a tile engine, all you have to do is replace the coordinates where the blting function is writing to the screen (I think they're called something like "DestX" and "DestY"). I can't give you the exact code, because it depends a lot on how you're storing the map
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  15. #15
    Member
    Join Date
    Sep 2001
    Location
    Quebec, Canada
    Posts
    43
    All right Jotaf, I tried it today, and it worked pretty well The basic engine still isn't complete, so I can't tell how fast it will be at the end, but it does a decent job. Thanks
    - Dr. Cossack

    Interordi.com: Internet tools, programming, games, and more!

  16. #16
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    You're welcome
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  17. #17
    Hyperactive Member
    Join Date
    Feb 2001
    Posts
    421

    your first question..

    Code:
    Private Sub Picture1_MouseDown(X...)
     Picture1.PlacePicture Image1.Picture, X, Y
    End Sub
    This is just a quick version, Image1 holds the tile. Also, make sure that AutoRedraw is True for Picture1.
    [vbcode]
    ' comment
    Rem remark
    [/vbcode]

  18. #18
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    That's for VB.Net, right?
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  19. #19
    Hyperactive Member
    Join Date
    Aug 1999
    Posts
    482
    Originally posted by Jotaf98


    What do you mean? How do you make it now?...
    This post above was directed to Kedaman..


    i'd like to hear the answer, too

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