Page 1 of 3 123 LastLast
Results 1 to 40 of 94

Thread: Fast and smooth graphics within a little game...

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636

    Lightbulb Fast and smooth graphics within a little game...

    Hi to all of you who read this thread!

    I want to get suggestions about the following:

    I want to make a little game (for example: 2D Football) with Fast and Smooth graphics!!
    The main tool I can use is Direct X 7.

    Any suggestions?

    Thank you in advance,
    Arie.

  2. #2
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    u can also use bitblt...its fast!
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  3. #3
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Not fast enough for 1024x768 fullscreen games thought.

  4. #4
    Addicted Member
    Join Date
    Aug 2002
    Posts
    192
    That's true. The big reason for that is that directx can draw directly to the front buffer rather than copying from a backbuffer.

  5. #5
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Not exactly... DX uses hardware acceleration wherever possible. You can't even BitBlt a single 1024x768 front buffers with reasonable performance. However for small games or such where you don't have to draw a full screen in each frame BitBlt is just fine. Though you don't get rotations and all the other nice features when using DXGraphics.

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636
    I want to make a full screen 800x600 game. I see that DX is the best choise this far...

    Any other suggestions?

    Arie.

  7. #7
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    OpenGL? But I would rather go with DX if I was you...

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636
    Ok... Direct X was chosen.
    Now, When I mess with the game loops, I usually use GetTickCount within a While loop. Should I use another looping tool?

    Thank you,
    Arie.

  9. #9
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Yes. Use a while loop, but instead of waiting for a specified time to elapse before updating your world state, instead, calculate the elapsed time between frames and update at each loop:
    Code:
    Dim l As Long
    Dim t As Long
    Dim delta As Single
    ...
    While running
      l = t
      t = GetTickCount()
      delta = (t - l) / 1000
      'Update
      'Draw
      DoEvents
    Wend
    You would then use delta in all update caluclations. For instance, an object is supposed to move 10 meters per second. You give that object a normalized (magnitude == 1) direction vector, and a velocity of 10. To calculate the new position of that object at each update you would do this:
    Code:
    nx = dir.x * vel * delta
    ny = dir.y * vel * delta
    This gives you correct, frame rate independant movement.

    Z.

  10. #10
    Addicted Member
    Join Date
    Aug 2002
    Posts
    192
    "Ah yes," thank you Fox. Hardware acceleration is the big reason. I left the screwdriver in my ear.

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636
    Ok, sounds good...
    Now, I have a Direct Draw Q:

    When I draw (BltFast) a surface that his width or height is out limited from the screen, it is not drawn. Why?

    Thank you,
    Arie.

  12. #12
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    I am not sure why it is doing that. But you have to calculate the width and hight and the X Y coordinates so it can fit on the screen. I can't remember if it is BlTFast or just Blt that has the oppurtunity to have all those values as parameters, but just try with BltFast first.

  13. #13

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636
    Got it. As a continue for the game building:
    When I want to get as many keys as possible at the same time.
    I usually use GetAsyncKeyState, but when I press many keys (3+) it doesn't get them... Maybe it's my comp.

    What is the way to get keys from the user?
    What should I use in a two or more players game?

    Thank you,
    Arie.

  14. #14
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    DX can handel your keyboard inputs too. But if you don't want to use it, you could always use the Key down and up events.

    Set a boolean variable (array?) to true for every key that is pushed in the key down event. Then in the game look, check what keys that is pushed and do what ever it is supposed to do. Then in the key up event set the boolean variables to false. And so on....

  15. #15
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Originally posted by Arie
    Got it. As a continue for the game building:
    When I want to get as many keys as possible at the same time.
    I usually use GetAsyncKeyState, but when I press many keys (3+) it doesn't get them... Maybe it's my comp.

    What is the way to get keys from the user?
    What should I use in a two or more players game?

    Thank you,
    Arie.
    The problem with many keys is actually a problem with the wiring in your keyboard... everyone's does that.

    Z.

  16. #16
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    try this:
    VB Code:
    1. Private Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long
    2. Dim bKeys(255) As Byte
    3.  
    4. Call GetKeyboardState(bKeys(0))
    5. If ((bKeys(vbKeyUp) And 128) = 128) And ((bKeys(vbKeyLeft) And 128) = 128) Then
    6.     'both keys are pressed
    7. End If
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  17. #17
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Originally posted by Zaei
    The problem with many keys is actually a problem with the wiring in your keyboard... everyone's does that.

    Z.

    With my method I am pretty sure that you could at leas press 6 keys at the same time....

  18. #18
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    I managed to make it work with 8 keys on my machine with the messiest code I could think of at this minute....look here....
    Attached Files Attached Files

  19. #19
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Originally posted by NoteMe
    I managed to make it work with 8 keys on my machine with the messiest code I could think of at this minute....look here....
    Right. There is an upper limit on all keyboards. It's a hardware problem.

    Z.

  20. #20
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    Whats wrong with DX Input???
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  21. #21

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636
    Originally posted by NoteMe
    I managed to make it work with 8 keys on my machine with the messiest code I could think of at this minute....look here....
    This is a good one NoteMe. Thank you.

    Now I want to ask:
    How do I test my Direct Play (Multiplayer) without using another comp?

    Thank you,
    Arie.

  22. #22
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    You should be able to start a server and a client on the same machine.

    Z.

  23. #23
    Junior Member
    Join Date
    May 2003
    Posts
    18
    where can i get a direct x programming tutorial???
    Whats a program without me involved?

  24. #24
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Try out dirextx4vb.com everything you nee there....and BTW look in the DX SDK too....some things you will find intresting there too....

  25. #25

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636
    How do I make a part of a surface rotate?

    Thank you,
    Arie.

  26. #26
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    Rotateing at runtime will sow your game down, you need to either load up a series of frames all of different rotation or rotate it before starting the game and rotate it into memory.

    Are you using DX or a picture box???
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  27. #27
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Use DXGraphics and simply rotate the edge points of the destination polygons that form your surface. See the Mouse Attack thread and download it's code; the DXGraphics module (especially the Blt function) might be of interest.

  28. #28

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636
    I am using Direct X, Direct Draw. How do I rotate a surface?

    Thank you,
    Arie.

  29. #29
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    See attached

    This is actually from my own app so a few changes are needed

    ByRef Pic1 As DirectDrawSurface7 = Returned Surface


    ByVal I As Integer = Angle (0 to 15) (16 Angles in my game)

    The RotateOffset Variable contains degrees per value of I this was for a quick change. To have it as 360 just change it to 1.

    UnitName As String = Folder name from app.path

    Position As String = Filename of picture


    I hope that makes sense
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  30. #30

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636
    See what attached? Where?

    Arie.

  31. #31
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    How strange
    Attached Files Attached Files
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  32. #32

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636
    Is this procedure fast?

    any other code?

    Thank you,
    Arie.

  33. #33
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    I didn't look at the other code, but here is an other example.....
    Attached Files Attached Files

  34. #34

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636
    This is an excellent example of Rotating a Surface!!!

    Thank you very much, NoteMe.

    Arie.

  35. #35
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    No problem. But remember that it is not as fast as if you make 60 pictures of the car at design time, and makes a sprite of all of them, and just changes the picture of the car if it moves....

  36. #36

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636
    Tried it on my game. Two notes:

    1) It is way too slow...

    2) I can't rotate a part of a surface.

    So you say that I have no other choise... I must draw 360 pictures?

    Thank you,
    Arie.

  37. #37
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    No that is not what I am saying. First of all, why do you need 360 pictures. You can't need one for every degree. That sounds like to many for a game. An other thing you could do is make a game that rotates and saves a picture in as many angles as you want. And if you are lucky I a have sutch a app....
    Last edited by NoteMe; May 30th, 2003 at 08:05 AM.

  38. #38
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Here it is....


    BTW why do you need to rotate parts of a surface. Show me an example of a surface that you need to rotate parts of it...
    Attached Files Attached Files

  39. #39
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    i improved the rotate function that NoteMe attached...its alot faster now!
    Attached Files Attached Files
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  40. #40
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    The first one I posted? Or the one that saves pictures that is rotated?

Page 1 of 3 123 LastLast

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