Weekly Qbasic and Qb64 Lesson Topics
August 16, 2018, 02:18:02 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  

My IDEA, a qb64 animation


Pages: [1]
  Print  
Author Topic: My IDEA, a qb64 animation  (Read 929 times)
GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« on: May 23, 2011, 08:38:12 pm »

Ok well here is a "rough ver" of my Idea,...no GIF, just qb64,.....
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)
volume = 1 '
gamestart = False '
intromusic = _SNDOPEN("Walking_1.wav", "VOL") '//You need to change this 'according to the name of the music file you use, Ie: bigger_better.mid
_SNDVOL intromusic, volume '
_SNDLOOP intromusic '
PRINT " Music, By Miles Davis and Jofn Coltrane "
_DELAY 1
PRINT " MY IDEA"
_DELAY 1

TYPE Rectangle
    X AS INTEGER
    Y AS INTEGER
    Width AS INTEGER
    Height AS INTEGER
END TYPE
Sprite& = _LOADIMAGE("ideasprtsheet.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&) / 5) STEP (_HEIGHT(Sprite&) / 5)
    FOR i% = 0 TO _WIDTH(Sprite&) - (_WIDTH(Sprite&) / 10) STEP (_WIDTH(Sprite&) / 10)
        SpriteImageRect(rectcnt%).X = i%
        SpriteImageRect(rectcnt%).Y = j%
        SpriteImageRect(rectcnt%).Width = _WIDTH(Sprite&) / 10
        SpriteImageRect(rectcnt%).Height = _HEIGHT(Sprite&) / 5
        rectcnt% = rectcnt% + 1
    NEXT
NEXT
DO
    '// Draw the images in turn.skip the last image as it is blank.
    FOR i% = 0 TO 48
        _PUTIMAGE (200, 100)-(420, 350), Sprite&, , (SpriteImageRect(i%).X, SpriteImageRect(i%).Y)-(SpriteImageRect(i%).X + SpriteImageRect(i%).Width, SpriteImageRect(i%).Y + SpriteImageRect(i%).Height)
        _DISPLAY
        _DELAY .2
        kb$ = INKEY$
        IF kb$ = CHR$(27) THEN SYSTEM
    NEXT
LOOP
 

---------------------------
Here is the drop box link, for the music,sprite sheet,and source (Idea.bas)
 http://dl.dropbox.com/u/15387474/QB64_IDEA.rar 
The name Bigger_better, is misleading, but I used that name because, it actually is for a bigger and better sprite sheet,that I am working on, (75 frames).
From Garry,
P.S.attached is the  sprite sheet
« Last Edit: September 14, 2011, 08:12:02 am by GarrisonRicketson » Report Spam   Logged

Social Buttons

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



WWW
« Reply #1 on: June 27, 2011, 07:53:36 am »

This is my newest on this, But  it is a boy danceing. I had trouble with useing a sprite sheet ,with frames that are small 120 x 94, when the image is enlarged to
the full window size, it becomes "rough", or not very clear,...so I made the sprite sheet with full size images and it looks better. There may be a better way to solve this, if anyone knows.
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

  
Attatched is the sprite sheet and
The music is on Drop Box:
http://dl.dropbox.com/u/15387474/QB64_DanceingBoy.zip
 

or you can download this ,it is the same sprite sheet,


« Last Edit: September 13, 2011, 08:46:12 pm by GarrisonRicketson » Report Spam   Logged

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



WWW
« Reply #2 on: September 13, 2011, 06:51:21 pm »

Thes are some ideas I had, I am still working on ways to improve them,..
Unseen posted a tutorial on useing sprtite sheets, the code he used to demonstrate, is what I am useing,..it is very versatile, and can accomadate many turpes of sprite sheets, with out compromise any of the movement.
Thank Unseen,..
from Garry
Report Spam   Logged


Pages: [1]
  Print  
 
Jump to:  

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

Buy traffic for your forum/website
traffic-masters
Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy