Moving with "sprites"
Author |
Message |
Diablo117
|
Posted: Sun May 31, 2009 6:28 pm Post subject: Moving with "sprites" |
|
|
What is it you are trying to achieve?
Moving my picture with a "walking sequence" of 1 to 4
What is the problem you are having?
Can't seem to make it scroll through without super lag
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>
Turing: |
%Custom Types
type gameObject :
record
X : int
Y : int
alive : boolean
ammo : int
clips : int
grenades : int
enemy : boolean
interactable : boolean
velocity : int
currWeap : int
moving : boolean
end record
%Variables
var player : gameObject
%Initializing Player
player.X := 0
player.Y := 0
player.alive := true
player.ammo := 30
player.clips := 5
player.currWeap := 1
player.moving := false
var Elite : array 1 .. 10 of gameObject
var Grunt : array 1 .. 20 of gameObject
var ch : string (1)
%Pictures
var playerRifleSprite := Pic.FileNew ("WieldingRifle.bmp")
var playerstandSprite := Pic.FileNew ("Standing.bmp")
var playerwalk1Sprite := Pic.FileNew ("Walking1.bmp")
var playerwalk2Sprite := Pic.FileNew ("Walking2.bmp")
var playerwalk3Sprite := Pic.FileNew ("Walking3.bmp")
var playerwalk4Sprite := Pic.FileNew ("Walking4.bmp")
var maxJump : int
var gravity : int
var keys : array char of boolean
var font1 := Font.New ("Halo:30")
%Start Screen
View.Set ("offscreenonly,graphics:700;400,nobuttonbar")
setscreen ("graphics")
colorback (black)
cls
Font.Draw ("Halo By Diablo117", 100, 200, font1, blue)
Font.Draw ("Press any key to continue", 50, 100, font1, blue)
getch (ch )
cls
%Drawing the player
proc playerDraw (weapon : int, walking : boolean)
var acounter : int := 1
%Draws the basic model
if walking = false then
Pic.Draw (playerstandSprite, player.X, player.Y, picMerge)
else
if acounter = 1 then
Pic.Draw (playerwalk1Sprite, player.X, player.Y, picMerge)
end if
acounter + = 1
end if
%What weapon is player using?
if weapon = 1 then
Pic.Draw (playerRifleSprite, player.X - 12, player.Y, picMerge)
end if
end playerDraw
loop
View.Update
cls
Input.KeyDown (keys )
if keys (KEY_RIGHT_ARROW) then
player.moving := true
player.X + = 10
else
player.moving := false
end if
playerDraw (player.currWeap, player.moving )
delay (50)
end loop
|
Please specify what version of Turing you are using
4.0.5 I think |
|
|
|
|
|
Sponsor Sponsor
|
|
|
tjmoore1993
|
Posted: Sun May 31, 2009 7:01 pm Post subject: RE:Moving with "sprites" |
|
|
|
|
|
|
|
|
Diablo117
|
Posted: Sun May 31, 2009 8:15 pm Post subject: Re: Moving with "sprites" |
|
|
Exactly what I want, unfortunately this "pauses" the program as the loop runs and an exit cant be used outside of a for or loop statement. I tried adding it in a few different ways but all of them paused my program while that ran. Any other suggestions? |
|
|
|
|
|
tjmoore1993
|
Posted: Sun May 31, 2009 8:27 pm Post subject: Re: Moving with "sprites" |
|
|
Diablo117 @ Sun May 31, 2009 8:15 pm wrote: Exactly what I want, unfortunately this "pauses" the program as the loop runs and an exit cant be used outside of a for or loop statement. I tried adding it in a few different ways but all of them paused my program while that ran. Any other suggestions?
What exactly are you trying to accomplish? Character moves while other things move? |
|
|
|
|
|
Dusk Eagle
|
Posted: Sun May 31, 2009 8:38 pm Post subject: Re: Moving with "sprites" |
|
|
You should be storing all your pictures of the one player in an array, as this makes it easier to expand your array to more pictures and to work with your pictures. Load each picture into memory by doing something like this:
Turing: |
var player_pic : array 1 .. 10 of int
for i : lower (player_pic ) .. upper (player_pic )
player_pic := Pic.FileNew ("picture" + intstr (i ) + ".jpg")
end for
|
Then draw the player to the screen using the following code:
Turing: |
var sprite_counter := 0
loop %this is the main loop of your program, treat it well, and add your other code into it.
if player_is_to_be_drawn then
Pic.Draw (positions, playerPic (counter )
sprite_counter + = 1
if sprite_counter > upper(player_pic ) then
sprite_counter := lower (player_pic )
end if
end if
end loop
|
|
|
|
|
|
|
Diablo117
|
Posted: Sun May 31, 2009 8:59 pm Post subject: Re: Moving with "sprites" |
|
|
Mmm, thanks ill try that now. I stopped using an array when my pictures wouldnt seem to load but it mightve been me being stupid elsewhere in the code. |
|
|
|
|
|
|
|