Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
question on determining time spent in area
#1
My goal in this program I am attempting to write is to tally up how much time the ball spends inside of the square area I have set aside in the screen.  I thought I would be able to subtract the time it exited from the time it entered the square to get the time spent inside.  But it seems that the constant update of the variable being used to hold result of the 'TIMER' command into is constantly updating due to the loop, so I can't seem to figure out how to get a single value for the time the circle's center actually crossed into the green square.  I was thinking something like endTime! - beginTime! would give me the number of seconds that the circle spent in the square.  


 
Code: (Select All)
CONST BALLRADIUS = 30
DIM ballx! 'ball x coordinate
DIM bally! 'ball y coordinate
DIM ballvecx! 'ball x vector
DIM ballvecy! 'ball y vector

SCREEN _NEWIMAGE(400, 400, 32)
ballx! = 50
bally! = 50
ballvecx! = .25
ballvecy! = .50



DO
    _LIMIT 60
    CLS
    LINE (100, 300)-(300, 100), _RGB32(0, 300, 0), BF

    ballx! = ballx! + ballvecx!
    bally! = bally! + ballvecy!
    IF ballx! > 370 OR ballx! < 30 THEN
        ballvecx! = -ballvecx!
    END IF
    IF bally! > 370 OR bally! < 30 THEN
        ballvecy! = -ballvecy!
    END IF
    IF bally! > 100 AND bally! < 300 AND ballx! > 100 AND ballx! < 300 THEN
        PRINT TIMER
    END IF

    CIRCLE (ballx!, bally!), BALLRADIUS
    PAINT (ballx!, bally!), _RGB32(255, 255, 255)
    _DISPLAY
LOOP UNTIL _KEYDOWN(27)
SYSTEM
Reply


Messages In This Thread
question on determining time spent in area - by fistfullofnails - 08-19-2025, 11:27 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  _Putimage Question. Pete 11 671 01-04-2026, 09:33 PM
Last Post: Pete
  Nice simple, I hope, question Mad Axeman 4 333 12-20-2025, 09:28 PM
Last Post: SMcNeill
  NewBie Question niteflyer 2 324 11-06-2025, 07:11 PM
Last Post: Petr
  A Question About _MAPTRIANGLE Magdha 2 372 11-02-2025, 11:37 AM
Last Post: Magdha
  '$include: 'file.tmr' Timing Question pmackay 2 427 10-16-2025, 12:20 PM
Last Post: a740g

Forum Jump:


Users browsing this thread: 1 Guest(s)