Results 1 to 3 of 3

Thread: Movements & Timer

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2013
    Posts
    12

    Movements & Timer

    I am making a falling game, where things fall and you have to avoid them. I'm using pictureboxes as the falling objects which are connected to a timer but I'm not really sure how to make it so then once the game stats the objects start falling. I know to go down is PictureBox.Top = PictureBox.Top -5 or whatever number, but how would I write it for a timer. I'm new to VB.Net.

  2. #2
    Fanatic Member
    Join Date
    Feb 2013
    Posts
    985

    Re: Movements & Timer

    Hi

    I assume you know a little bit about a timer
    1 you start the timer
    2 the timer counts down
    3 when countdown is 0 then the 'Tick' event is fired
    ---you would put your frame update code in the tick event
    4 timer starts again(as long as its set to, by default it will repeat)

    tips with the coding:

    when i say frame-update code that means EVERYTHING that changes in game should be calculated here in the tick event.
    keyboard presses, object movement, colision detection(if any), score updates,


    Recommendation:
    due to having some sort of problem using a timer in many different situations i recommend creating a loop of you own and putting an if statement to fire after a certain time has passed. using system clock ticks as a time reference, its really simple

    tickcount= 'system clock ticks'

    while playinggame = true 'game started'
    if tickcount + 100 <= systemtickcount then 'tickcount+100 <= systemtickcount which means at least 100ms has passed before the frame is updated
    <frame update code here>
    tickcount = systemtickcount
    end if
    wend

    dont forget to stop the loop when the game has ended or someone died etc,
    playinggame = false

    hope this helps
    Yes!!!
    Working from home is so much better than working in an office...
    Nothing can beat the combined stress of getting your work done on time whilst
    1. one toddler keeps pressing your AVR's power button
    2. one baby keeps crying for milk
    3. one child keeps running in and out of the house screaming and shouting
    4. one wife keeps nagging you to stop playing on the pc and do some real work.. house chores
    5. working at 1 O'clock in the morning because nobody is awake at that time
    6. being grossly underpaid for all your hard work


  3. #3
    Fanatic Member
    Join Date
    Feb 2013
    Posts
    985

    Re: Movements & Timer

    Heres a quickreference on system tick count
    <<LINK>>
    Yes!!!
    Working from home is so much better than working in an office...
    Nothing can beat the combined stress of getting your work done on time whilst
    1. one toddler keeps pressing your AVR's power button
    2. one baby keeps crying for milk
    3. one child keeps running in and out of the house screaming and shouting
    4. one wife keeps nagging you to stop playing on the pc and do some real work.. house chores
    5. working at 1 O'clock in the morning because nobody is awake at that time
    6. being grossly underpaid for all your hard 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