Results 1 to 31 of 31

Thread: How to clear only the ship(A newbie at game programming)Plz help

  1. #1

    Thread Starter
    Hyperactive Member toughcoder's Avatar
    Join Date
    Nov 2002
    Location
    Near, Very Near
    Posts
    340

    How to clear only the ship(A newbie at game programming)Plz help

    Hello Every1,
    I'm have just started game programming & have a small doubt. I want to make a small game just like arkanoid. I have made a procedure called DrawGameArea() which draws the border & the scoring, lives & hint area. Now to move the paddle i have to clear the screen everytime. So when drawing the paddle, i have to call the DrawGameArea() procedure also to draw the game area. Is there a way so that i have to clear only the paddle & the rest of the screen remains the same. Or any other way of doing this stuff. I'm pretty much a newbie at game programming so thought maybe some1 can help on this. Thanx in advance.
    If Not VB Then Exit
    ------------------------------------------------
    visit me @ http://mzubair.50g.com/

  2. #2
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Are you using BitBlt or DX or what???

  3. #3
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    In general you WANT to clear the screen each frame.

    Z.

  4. #4
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    But if the background don't move, you can only Blt the size of what is moving at the point it was before it moved, and then Blt the picture to where oyu want to move it. In a game with no scrooling background, this will improve speed a lot...

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Only in API, not in DirectX.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  6. #6
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Originally posted by CornedBee
    Only in API, not in DirectX.
    What do you mean...not improve speed or not possible in DX???

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Not improve speed - not much at least.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  8. #8
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    I have never tested the speed improvement, but I think it is a reason for the DX SDK to have an example on how to do it, and J. Harbour to have an example in his book on how to do it....but I have not tested it so I can't tell how much inprovment....

  9. #9
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    I believe the improvement is not worth the additional work - to test which areas are invalidated and such. The whole concept is probably only usable for simple games (not any 3d games due to the techniques used) without too much extra work, and for those games the speed gain is irrelevant.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  10. #10
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    No....not 3D games. I'm talking about 2D games with a non scrolling background. That is what it is used for....

  11. #11
    Member anjulpa's Avatar
    Join Date
    Aug 2001
    Location
    india
    Posts
    43
    draw a balck(background color) bar where your bar was previously and draw the white one at the new place. there, so simple !

    ppl saw this
    Die, ***** Die !

  12. #12
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Originally posted by NoteMe
    No....not 3D games. I'm talking about 2D games with a non scrolling background. That is what it is used for....
    I'm currently writing such a game in C#. I still repaint everything everytime simply because it's easier. Such a game does not need the speed gain you have.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  13. #13
    Member anjulpa's Avatar
    Join Date
    Aug 2001
    Location
    india
    Posts
    43
    maybe he's doing something much more resource extensive like a physics engine or hi-fi collissions and he wants toinch every single cpu cycle.

    ppl saw this
    Die, ***** Die !

  14. #14
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Yeah, but in that kind of game you can't even place that many objects if you use a good collision algorithm.
    Physics modelling doesn't take that many cycles.
    AI might be an issue, yes.

    But if the card supports hardware blitting (nearly all modern cards do) then you might use more CPU cycles determining what to redraw than actually redrawing everything. Hardware blitting can be in parrallel with other calculations.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  15. #15
    Member anjulpa's Avatar
    Join Date
    Aug 2001
    Location
    india
    Posts
    43
    true but there are physics engines that could clog your fps right to their very roots. like karma of course, in ut 2003, i get 5 fps on my 32 mb card if i use full physics details with 5 bots. aargh !!

    ppl saw this
    Die, ***** Die !

  16. #16
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    And then, we ARE assuming VB here, and if you want every CPU cycle, you arent using VB

    Z.

  17. #17
    Member anjulpa's Avatar
    Join Date
    Aug 2001
    Location
    india
    Posts
    43
    true

    ppl saw this
    Die, ***** Die !

  18. #18
    Hyperactive Member BramVandenbon's Avatar
    Join Date
    Jan 2002
    Location
    Belgium
    Posts
    502
    not(False)
    ____________________________________________

    Please rate my messages. Thank you!
    ____________________________________________
    Bram Vandenbon
    http://www.bramvandenbon.com

  19. #19
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    (!false)

  20. #20
    Hyperactive Member BramVandenbon's Avatar
    Join Date
    Jan 2002
    Location
    Belgium
    Posts
    502
    !0
    ____________________________________________

    Please rate my messages. Thank you!
    ____________________________________________
    Bram Vandenbon
    http://www.bramvandenbon.com

  21. #21
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    -4

    Z.

  22. #22
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    I have to admitt I couldn't understand the logic befind the last one, so I think the VBForums compiler got an error, and terminated this thread...

  23. #23
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Originally posted by NoteMe
    I have to admitt I couldn't understand the logic befind the last one, so I think the VBForums compiler got an error, and terminated this thread...
    What, the -4? Non-Zero == true, Zero == false.

    Z.

  24. #24
    Hyperactive Member BramVandenbon's Avatar
    Join Date
    Jan 2002
    Location
    Belgium
    Posts
    502
    Sorry for wasting the topic, people ... Let's get back to the last usefull post
    ____________________________________________

    Please rate my messages. Thank you!
    ____________________________________________
    Bram Vandenbon
    http://www.bramvandenbon.com

  25. #25
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Originally posted by Zaei
    And then, we ARE assuming VB here, and if you want every CPU cycle, you arent using VB

    Z.

    This was the last real post. And it is true. But you can always, say that. Vb is to slow...so why not use C++...C++ is too slow, so why not use ASM, ASM is too slow, why not make a chip set from scratch.....

  26. #26
    Member anjulpa's Avatar
    Join Date
    Aug 2001
    Location
    india
    Posts
    43
    why not make bubble memory chambers of own, or maybe nanoelectronics (!bad)

    ppl saw this
    Die, ***** Die !

  27. #27
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Anyway, I think the standard spectrum analyzer plugin of winamp erases only the parts of the screen that might have changed (= the wave part, the spectrum part and every second the song title part)
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  28. #28
    Fanatic Member
    Join Date
    Dec 2002
    Location
    North Carolina
    Posts
    734
    Heh, his own thread and tough coder only posted to start it.

  29. #29
    Member anjulpa's Avatar
    Join Date
    Aug 2001
    Location
    india
    Posts
    43
    LOL

    ppl saw this
    Die, ***** Die !

  30. #30

    Thread Starter
    Hyperactive Member toughcoder's Avatar
    Join Date
    Nov 2002
    Location
    Near, Very Near
    Posts
    340
    Hey guys, u r all off the track a bit. Cmon, help me out. Well, i'm using only BitBlt to achieve this. can u guys help...
    If Not VB Then Exit
    ------------------------------------------------
    visit me @ http://mzubair.50g.com/

  31. #31
    Addicted Member Osiris's Avatar
    Join Date
    Oct 2000
    Location
    Dimension Hole
    Posts
    142
    clear the paddle only?
    what about the bouncing ball and the blocks that you have to hit?
    they need to be redrawn as well...

    you said you only want to clear and redraw the paddle

    just a thought...
    have 3 pictureboxes:
    ×----MAIN: will be the final output
    x----BG: will contain the background HDC(so you dont redraw)
    X----backbuffer: copy BG to this 1rst, then the paddle & other
    things that need to be animated(ball, blocks) and after everything
    is drawn here, Bitblt everything to MAIN

    probably this will make it slower since you are adding extra
    pictureboxes...
    ______
    another option would be to copy the background area where you
    are going to put the paddle, and store it somewhere along with
    it's X and Y position where it was taken from in the picturebox...
    then bitblt the paddle on that area, to erase it, just copy the
    area that you had stored before and put it back to it's X & Y
    position.

    I dont know if I explained that last one good, or I left out anything, well, ::yawn::, feeling sleepy but not gonna go to
    sleep, laters
    ؊Ϯϊ

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