Author Topic: moving graphic from offscreen to onscreen and stopping at specific xres  (Read 2596 times)

0 Members and 1 Guest are viewing this topic.

Offline ttemper

  • Amiga 1200
  • ****
  • Posts: 267
  • Karma: 7
    • View Profile
another newbie question...

so i have been messing with graphics in freebasic (tinyptc_ext) and at the moment i have the graphic centered on screen and 200px down from X on a 800x600res screen eg..
|---------------|
|---graphic---|
|---------------|

what im attempting to do is have the graphic move from off screen (top center) and move it down smoothly until it reaches position 200px on xres.

i (sort of) understand the concept, and have tried this with...

Code: [Select]
SUB MOVEINLOGO ()
DIM AS UINTEGER LMOVE
LMOVE = 0
FOR LMOVE=0 TO 200
DRAWIMAGE(78.5,LMOVE)
LMOVE+=1
NEXT
END SUB

but being an utter code newbie, i found out this renders the graphic on screen 255 times moving it down 1px on xres each loop. i did try a different way, but it went from 0 to 255 in a heartbeat, and blitted it on screen straight away at 200px, so that kinda defeated the purpose of what im trying to achieve.

ive tried searching on freebasic forums for help, but no luck. so again, im writing here. i'm sure its easy to do, but extremely difficult for me at the moment.

so basically i want to move the graphic from offscreen (a) to onscreen at xres 200px (b) in a nice smooth (timed) motion, and once it reaches position b, stop and just blit the graphic there (static) for the rest of the duration.

thanks in advance!







Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
You want something like
Code: [Select]
lmove=0
do
  cls
  ...other demo stuff
  drawimage(78.5, lmove)
  if lmove < 200  lmove+=1
  flip screen
while 1

Where the do/while loop is your demo's main drawing loop.  That should then take about 200/60seconds to move down.

Jim
Challenge Trophies Won:

Offline ttemper

  • Amiga 1200
  • ****
  • Posts: 267
  • Karma: 7
    • View Profile
awesome, much thanks again jim. i know its probably the most simple thing to do, yet i seem to get stuck by putting the loop or the code in the wrong place.

slowly learning my way around freebasic, every little bit of help is much appreciated.