|
Post by shadow008 on Sept 11, 2009 13:34:49 GMT -5
kk. as ive stated befor, i suck with 2d and ive tried all the tricks i know and still i havent been able to figure out how to have multiple animations going at once. if you wanna help plz show me how to do something simple like mult stick figures on the demo...
|
|
|
Post by Adam on Sept 11, 2009 15:10:50 GMT -5
Here, a modded Stick dude program, just for you TextMode (TEXT_BUFFERED) locate 0, 3 printr " !Stick Dude!" printr printr " Use arrow keys and space bar"
' Load in all image frames dim allImages(ImageStripFrames("data\StickDude.png") - 1) allImages = LoadImageStrip("data\StickDude.png")
' Split up frames into separate animations dim standImage, jumpImage, walkAnim(3), climpAnim(3)
' Frame 0 is standing still standImage = allImages(0)
' Frames 1-4 are walking (right) walkAnim(0) = allImages(1) walkAnim(1) = allImages(2) walkAnim(2) = allImages(3) walkAnim(3) = allImages(4)
' Frame 5 is jumping jumpImage = allImages(5)
' Frames 6-9 are climbing (up) climpAnim(0) = allImages(6) climpAnim(1) = allImages(7) climpAnim(2) = allImages(8) climpAnim(3) = allImages(9) ' Display animation frames ' Create the sprite dim sprite(1) dim i Sprite(0) = NewSprite(standImage) SprSetPos(590, 240) Sprite(1) = NewSprite(standImage) SprSetPos(50,240)
' Main animation loop while true BindSprite(Sprite(0)) ' Set the sprite animation and direction based on the ' key being pressed if ScanKeyDown(VK_SPACE) then ' Display jump image For I = 0 To 1 BindSprite(Sprite(i)) SprSetTexture(jumpImage) Next
elseif ScanKeyDown(VK_LEFT) then ' Display walk animation For I = 0 To 1 BindSprite(Sprite(i)) SprSetTextures(walkAnim) SprSetAnimSpeed(.2) ' Flip it so it faces left SprSetXFlip(-i*2*2) ' Move sprite left SprSetVel(-i*2+1, 0) Next
elseif ScanKeyDown(VK_RIGHT) then ' Display walk animation For I = 0 To 1 BindSprite(Sprite(i)) SprSetTextures(walkAnim) SprSetAnimSpeed(.2) ' Unflipped, so it faces right SprSetXFlip(-i*2+2) ' Move sprite right SprSetVel(i*2-1, 0) next
elseif ScanKeyDown(VK_UP) then ' Display climp animation For I = 0 To 1 BindSprite(Sprite(i)) SprSetTextures(climpAnim) SprSetAnimSpeed(.2) ' Move sprite up SprSetVel(0, -i*4+2) next
elseif ScanKeyDown(VK_DOWN) then ' Display climb animation, going backwards For I = 0 To 1 BindSprite(Sprite(i)) SprSetTextures(climpAnim) SprSetAnimSpeed(-.2) ' Move sprite down SprSetVel(0, i*4-2) next
else ' Display standing image For I = 0 To 1 BindSprite(Sprite(i)) SprSetTexture(standImage) ' Stop sprite SprSetVel(0, 0) next
endif ' AnimateSprites automatically animates and moves all sprites AnimateSprites() ' DrawText draws the sprites to screen DrawText() ' WaitTimer slows down the main loop so things don't happen too fast WaitTimer(20) wend
|
|
|
Post by shadow008 on Sept 12, 2009 18:54:49 GMT -5
?... (looks at code)... oh! so thats what i was doing wrong, thanks for the help man : )
|
|
|
Post by twasik4 on Sept 23, 2009 15:12:55 GMT -5
lol, cole your always doing something wrong... lol
|
|
|
Post by Darkjester on Oct 2, 2009 15:08:43 GMT -5
Way to be supportive
|
|