Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Sprites flashing, spazzing
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
paperclipz




PostPosted: Thu Nov 29, 2007 12:15 pm   Post subject: Sprites flashing, spazzing

I finally got one of my sprites working. Heres the code im using
code:

const fileName1 := "spawnwalkingwest.gif"
const fileName := "spawnwalkingeast.gif"
const fileName2 := "spawnattackwest.gif"
const fileName3 := "spawnattackeast.gif"
var numFrames : int := Pic.Frames (fileName)
var numFrames1 : int := Pic.Frames (fileName1)
var numFrames2 : int := Pic.Frames (fileName2)
var numFrames3 : int := Pic.Frames (fileName3)
var stand:int:= Pic.FileNew ("spawnstanding.bmp")
var x:int
var y:int
var sora_x, sora_y:int




% Load the picture
var sora_stand: int
sora_stand:=Sprite.New(stand)

var delayTime : int
var pics : array 1 .. numFrames of int
var pics1 : array 1 .. numFrames1 of int
var pics2 : array 1 .. numFrames2 of int
var pics3 : array 1 .. numFrames3 of int
Pic.FileNewFrames (fileName, pics, delayTime)
Pic.FileNewFrames (fileName1, pics1, delayTime)
Pic.FileNewFrames (fileName2, pics2, delayTime)
Pic.FileNewFrames (fileName3, pics3, delayTime)




% Display the pictures
x:=100
y:=10



loop
sora_x:= x+2
sora_y:= y-1

Sprite.SetPosition (sora_stand,sora_x,sora_y,false)
Sprite.Show (sora_stand)


var chars : array char of boolean
            Input.KeyDown (chars)
           
            if chars ('a')and chars(KEY_RIGHT_ARROW) then
           
             Pic.DrawFrames (pics3, x, y, picMerge, upper (pics3), 70, true)
   
           end if
           
           if chars ('a')and chars(KEY_LEFT_ARROW) then
           
             Pic.DrawFrames (pics2, x, y, picMerge, upper (pics2), 70, true)
   
           end if
           
            if chars (KEY_LEFT_ARROW) then
                x:=x-10
               
Pic.DrawFrames (pics1, x, y, picMerge, upper (pics1), 55, true)
     
            end if
            if chars (KEY_RIGHT_ARROW) then
                x:=x+10
       

    Pic.DrawFrames (pics, x, y, picMerge, upper (pics), 55, true)   
            end if
           
           
           

   
           

end loop


whats going on is whenever im trying to move, the main picture of him standing in one place consistently shows up. When i move west, a black screen pops up surrounding the vicinity of the sprite and red/white dots show up in this box. If anyone knows what to help me with it would be much appreciated. Thanks.
Sponsor
Sponsor
Sponsor
sponsor
isaiahk9




PostPosted: Tue May 06, 2008 5:26 pm   Post subject: Re: Sprites flashing, spazzing

I am not positive but I believe that it is because you are using the "flashy" animation technique. To make it un-flashy, all you need to do is put setscreen("offscreenonly") on the top of the code, and then whenever you want to draw or display something put View.Update. That should take care of your problem, but I'll monitor this post in case it doesn't.
Saad




PostPosted: Tue May 06, 2008 5:41 pm   Post subject: Re: Sprites flashing, spazzing

isaiahk9 @ Tue May 06, 2008 5:26 pm wrote:
I am not positive but I believe that it is because you are using the "flashy" animation technique. To make it un-flashy, all you need to do is put setscreen("offscreenonly") on the top of the code, and then whenever you want to draw or display something put View.Update. That should take care of your problem, but I'll monitor this post in case it doesn't.


Let me provide more insight into the "flashy" animation technique. What's really going on is that as your drawing something it is instantly drawn in the screen. This means you keep saying each thing getting drawn. As a result it creates flickering. What doing View.Set ("offscreenonly") does is create an off-screen buffer onto which the graphics are drawn. When View.Update the changes are applied to the screen.

This link goes over how to use each in more detail and with some code.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: