Results 1 to 10 of 10

Thread: My 1st game

  1. #1

    Thread Starter
    Lively Member lil_bugga's Avatar
    Join Date
    Nov 2006
    Location
    Bishop's Stortford, Hertfordshire, UK
    Posts
    68

    Question My 1st game

    Hi all, im trying to create my own version of the classic Pong with realistic physics.

    I have the game set up for testing at the moment, i want to get things right so i can have the ball bounce of all 4 sides of the form. Unfortunatley my coding only works on the top and left walls where I have set the value 0.

    On the right and bottom walls the ball just continues right on through rather than bouncing back. I've tried using specific values to make the ball bounce as well as using the forms width added to the left and height added to the top but still to no avail.

    Can someone have a look an see where I've gone wrong, im assuming its something I've done or missed.

    Many Thanks
    Ben
    Attached Files Attached Files
    Last edited by lil_bugga; Aug 13th, 2007 at 07:18 PM.

  2. #2
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,621

    Re: My 1st game

    it's a comon problem. Without even looking, i would bet you didn't divide the twips properly.
    My light show youtube page (it's made the news) www.youtube.com/@artnet2twinkly
    Contact me on the socials www.facebook.com/lordorwell

  3. #3

    Thread Starter
    Lively Member lil_bugga's Avatar
    Join Date
    Nov 2006
    Location
    Bishop's Stortford, Hertfordshire, UK
    Posts
    68

    Re: My 1st game

    Quote Originally Posted by Lord Orwell
    it's a comon problem. Without even looking, i would bet you didn't divide the twips properly.
    As far as im aware i should be working in twips, and its 1 pixel to 15 twips i believe.

    To get the figures for the right and bottom i placed the image of the ball at the furthest point i want it to be then took the left and top co ords

  4. #4
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,621

    Re: My 1st game

    ok i was wrong. Your problem is a little more simple than that. You are mixing data types. You are treating xangle and yangle as strings by using the replace function on them. This is wrong. When you replace -10 with a + it makes it 10, not +10, so when you get to the other side of the screen and check for the boundary, there is no + to replace.
    My light show youtube page (it's made the news) www.youtube.com/@artnet2twinkly
    Contact me on the socials www.facebook.com/lordorwell

  5. #5

    Thread Starter
    Lively Member lil_bugga's Avatar
    Join Date
    Nov 2006
    Location
    Bishop's Stortford, Hertfordshire, UK
    Posts
    68

    Re: My 1st game

    Quote Originally Posted by Lord Orwell
    ok i was wrong. Your problem is a little more simple than that. You are mixing data types. You are treating xangle and yangle as strings by using the replace function on them. This is wrong. When you replace -10 with a + it makes it 10, not +10, so when you get to the other side of the screen and check for the boundary, there is no + to replace.
    Ok im with you there and now you've pointed it out to me it makes sence.

    Is there a way in which i can still get the same effect that I was aiming for in my attempt, whats the best way for me to do this, to mirror the angle of bounce that is?

    Thanks for the quick responces

  6. #6
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,621

    Re: My 1st game

    say for example that xangle = - 10
    Code:
    xangle = xangle * -1
    now xangle = 10
    (works both ways)
    My light show youtube page (it's made the news) www.youtube.com/@artnet2twinkly
    Contact me on the socials www.facebook.com/lordorwell

  7. #7
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,621

    Re: My 1st game

    Quote Originally Posted by lil_bugga
    As far as im aware i should be working in twips, and its 1 pixel to 15 twips i believe.

    To get the figures for the right and bottom i placed the image of the ball at the furthest point i want it to be then took the left and top co ords
    This is exactly why microsoft did away with twips in vb.net.

    there is not a standard relationship between twips and pixels. The number changes depending on monitor size and screen resolution. It's supposed to be something like 1000 per inch, no matter what. As you can see the ration would change if you had less pixels per inch or more from changing display settings or having a bigger monitor. You would have a much easier time of it i think if you used pixels, but in your particular case, it might be easier to make the ball move at angles more precisely using twips because of the multiple-twips-per-pixel.
    My light show youtube page (it's made the news) www.youtube.com/@artnet2twinkly
    Contact me on the socials www.facebook.com/lordorwell

  8. #8

    Thread Starter
    Lively Member lil_bugga's Avatar
    Join Date
    Nov 2006
    Location
    Bishop's Stortford, Hertfordshire, UK
    Posts
    68

    Re: My 1st game

    Thanks so much for your help

    I've modified my coding to impliment the codeing that you suggested and it now works well.


  9. #9
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,621

    Re: My 1st game

    i forgot to mention that you can convert twips to pixels by dividing by screen.twipsperpixelx and screen.twipsperpixely respectively
    My light show youtube page (it's made the news) www.youtube.com/@artnet2twinkly
    Contact me on the socials www.facebook.com/lordorwell

  10. #10
    Member
    Join Date
    Sep 2007
    Posts
    58

    Re: My 1st game

    this looks really good.. keep up the good work

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