Weekly Qbasic and Qb64 Lesson Topics
March 28, 2024, 05:14:16 pm
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Want to see a specific Tutorial? ASK!
 
  Home Help Search Arcade Links Staff List Login Register  

Animations with QB64

Pages: [1]
  Print  
Author Topic: Animations with QB64  (Read 2744 times)
GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« on: September 13, 2011, 07:54:56 pm »

My favorite thing is animations, there is some really neat stuff you can do with qb64, creating animations,..this is pretty basic. But if one uses they're imagination, just useing this little bit of simple code, one can do an entire animation.
Code:
REM Much thanks to Unseen, and his "useing a sprite sheet" tutorial, so it code I used to do this.
SCREEN _NEWIMAGE(600, 400, 32)
WINDOW SCREEN(200, 100)-(420, 250)
volume = 1 '
gamestart = False '
intromusic = _SNDOPEN("walking_1.wav", "VOL") '
_SNDVOL intromusic, volume '
_SNDLOOP intromusic '
PRINT " Music, Garry"
_DELAY 1
PRINT " MY DRAWINGS "
_DELAY 1

TYPE Rectangle
    X AS INTEGER
    Y AS INTEGER
    Width AS INTEGER
    Height AS INTEGER
END TYPE
Sprite& = _LOADIMAGE("dibujo.png")
'// GARY SAYS The sprite we are using has 49 frames, it has 10 frames on the X axis and 5 on the Y axis.
'// As we are dealing with an equally spaced sprite sheet we can load all the x/y points in a set of for loops.
DIM SpriteImageRect(50) AS Rectangle
FOR j% = 0 TO _HEIGHT(Sprite&) - (_HEIGHT(Sprite&) / 6) STEP (_HEIGHT(Sprite&) / 6)
    FOR i% = 0 TO _WIDTH(Sprite&) - (_WIDTH(Sprite&) / 2) STEP (_WIDTH(Sprite&) / 2)
        SpriteImageRect(rectcnt%).X = i%
        SpriteImageRect(rectcnt%).Y = j%
        SpriteImageRect(rectcnt%).Width = _WIDTH(Sprite&) / 2
        SpriteImageRect(rectcnt%).Height = _HEIGHT(Sprite&) / 6
        rectcnt% = rectcnt% + 1
    NEXT
NEXT
DO
    '// Draw the images in turn.skip the last image as it is blank.
    FOR i% = 0 TO 11
        _PUTIMAGE (200, 100)-(420, 250), Sprite&, , (SpriteImageRect(i%).X, SpriteImageRect(i%).Y)-(SpriteImageRect(i%).X + SpriteImageRect(i%).Width, SpriteImageRect(i%).Y + SpriteImageRect(i%).Height)
        _DISPLAY
        _DELAY .2 '////this is the _delay, can be changed to fit the music
        kb$ = INKEY$
        IF kb$ = CHR$(27) THEN SYSTEM
    NEXT
LOOP
 
This is  the links to the sprite sheet, and music.:
http://dl.dropbox.com/u/15387474/QB64_DanceingBoy.zip


 Enjoy it, and feel free to ask any questions,..I have one, if any one knows,..
 My next step with this would be to instead of exiting the program,the user has 2 choices,..they can go to the next animation,..and there would be another short animation, or they can exit the program. When I figure that out I will update this.
thanks
from Garry
« Last Edit: September 13, 2011, 08:23:56 pm by GarrisonRicketson » Report Spam   Logged

Share on Facebook Share on Twitter

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #1 on: September 15, 2011, 11:01:43 pm »

For anyone that would just like to run the animation, I have made a WinRar package ,with a executable, and also all the source code, and instructions,..here it is:
[size=150]Danceing Boy Download[/size] I like it much better then the .gif version, and the SWF version.
Report Spam   Logged


Pages: [1]
  Print  
 
Jump to:  

Powered by EzPortal
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum


Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy