Sprite.ChangePic (changing the sprites pictures)
Author |
Message |
drummaboy
|
Posted: Sat Dec 05, 2009 1:44 pm Post subject: Sprite.ChangePic (changing the sprites pictures) |
|
|
What is it you are trying to achieve?
I'm trying to make my sprite image keep on changing.
What is the problem you are having?
The image doesn't change until you let go of the arrow key
Describe what you have tried to solve this problem
I've tried putting it in a loop but that didn't work.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing: |
process DoMusic
loop
Music.PlayFile ("mario.mp3")
end loop
end DoMusic
fork DoMusic
% var statements and constants
var posx, posy : int
var velx, vely : real
const groundheight := 5
posx := 21
posy := 5
velx := 0
vely := 0
const runspeed := 1
const gravity := 1
var mario, marior, mariosl, mariol, mariojl, mariojr : int % mariostandleft and mario left
var spr, spr1, spr2, spr3, spr4, spr5, spr6, spr7 : int
var platform, tunnel : int
var infinite : int
infinite := 1000000
% End of var statments and constants ... Drawing Scenery
drawfillbox (0, 0, maxx, maxy, 52)
drawfillbox (0, 0, maxx, 21, brightgreen)
%cloud 1
drawfilloval (0, 350, 10, 10, white)
drawfilloval (15, 350, 10, 10, white)
drawfilloval (30, 350, 10, 10, white)
%cloud 2
drawfilloval (100, 350, 10, 10, white)
drawfilloval (115, 350, 10, 10, white)
drawfilloval (130, 350, 10, 10, white)
%cloud 3
drawfilloval (200, 350, 10, 10, white)
drawfilloval (215, 350, 10, 10, white)
drawfilloval (230, 350, 10, 10, white)
%sun
drawfillarc (maxx - 20, maxy - 25, 25, 50, 50, 410, yellow)
% Draw platform
tunnel := Pic.FileNew ("tunnel.bmp")
spr7 := Sprite.New (tunnel )
Sprite.SetPosition (spr7, 550, - 5, false)
Sprite.SetHeight (spr7, 10)
Sprite.Show (spr7 )
platform := Pic.FileNew ("platform.bmp")
spr2 := Sprite.New (platform )
Sprite.SetPosition (spr2, 300, 45, true)
Sprite.SetHeight (spr2, 10)
Sprite.Show (spr2 )
%End of Drawing Scenery and Start of Drawing Mario
mario := Pic.FileNew ("mariostand.bmp")
spr := Sprite.New (mario )
marior := Pic.FileNew ("marioright.bmp")
spr1 := Sprite.New (marior )
mariosl := Pic.FileNew ("mariostandL.bmp")
spr3 := Sprite.New (mariosl )
mariol := Pic.FileNew ("marioleft.bmp")
spr4 := Sprite.New (mariol )
mariojl := Pic.FileNew ("jumpleft.bmp")
spr5 := Sprite.New (mariojl )
mariojr := Pic.FileNew ("jumpright.bmp")
spr6 := Sprite.New (mariojr )
var chars : array char of boolean
loop
Input.KeyDown (chars )
if chars (KEY_RIGHT_ARROW) then
Sprite.ChangePic (spr, marior )
delay (10)
Sprite.ChangePic (spr, mario )
posx + = 1
elsif chars (KEY_LEFT_ARROW) then
Sprite.ChangePic (spr, mariol )
delay (10)
Sprite.ChangePic (spr, mariosl )
posx - = 1
if chars ('z') then
Sprite.ChangePic (spr, mariojl )
delay (10)
Sprite.ChangePic (spr, mariojr )
vely + = 10
end if
% this is where vely and velx contradict with the position
vely - = gravity
posx + = round (velx )
end if
Sprite.SetPosition (spr, posx, posy, false)
Sprite.SetHeight (spr, 10)
Sprite.Show (spr )
if posy = 45 then
posy := 45
end if
end loop
|
Please specify what version of Turing you are using
4.1.1 Turing (which i think is 4.1)
Oh and can you please tell me how to attach folders so it makes it easier than downloading one image at a time
Description: |
|
Filesize: |
4.74 KB |
Viewed: |
1279 Time(s) |
|
Description: |
|
Filesize: |
4.74 KB |
Viewed: |
1279 Time(s) |
|
Description: |
|
Filesize: |
4.74 KB |
Viewed: |
1279 Time(s) |
|
Description: |
|
Filesize: |
4.74 KB |
Viewed: |
1279 Time(s) |
|
Description: |
|
Filesize: |
4.74 KB |
Viewed: |
1279 Time(s) |
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
|
|