Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Fri Apr 19, 2019 11:53 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: SpriteSurface trailing
PostPosted: Thu Sep 10, 2009 5:41 pm 
Offline

Joined: Wed Sep 02, 2009 10:57 am
Posts: 2
Hi, I am relatively new to RealBasic and I'm using it for my preliminary Software Design and Development Course.
I'm creating a maze game on a SpriteSurface for my assessment but I have ran into a problem involving all moving sprites.

For Example:
When your 'character' ingame moves on the SpriteSurface, it leaves behind a 'ghost' image of it creating a trail of ghostly images.
When an animation occurs such as a Fireball moving across the screen, it also leaves behind a ghost image.
And if a Sprite is closed on collision a ghost image is left behind.

An example in screenshot:
Image

As you can see, the tank has left behind ghost images, as has the fireball and the rotating coin has a flawed display due to not removing the previous frame.

My teacher said she ran a new program with the coding from my NextFrame and recieved the same trailing and can't figure out why.

Here is my NextFrame Coding, if you need the full project I'll upload it somewhere.
Dim i As Integer
'move around using cursor keys
If levelprogress<>5 then
if spritesurface1.keytest(&h7c) and grid (down,across+1)="1" then 'right key
runner.image=tankright
runner.x = runner.x+29
across=across +1
elseif spritesurface1.keytest(&h7b) and grid (down,across-1)="1" then 'left key
runner.image=tankleft
runner.x = runner.x-29
across=across -1
elseif spritesurface1.keytest(&h7e) and grid (down-1,across)="1" then 'up key
runner.image=tankup
runner.y = runner.y-29
down=down -1
elseif spritesurface1.keytest(&h7d) and grid (down+1,across)="1" then 'down key
runner.image=tankdown
runner.y = runner.y+29
down=down +1
end if
End IF
If LevelProgress =5 then
if spritesurface1.keytest(&h7c) and grid (down,across+1)="1" then 'right key
runner.image=shuttleright
runner.x = runner.x+29
across=across +1
elseif spritesurface1.keytest(&h7b) and grid (down,across-1)="1" then 'left key
runner.image=shuttleleft
runner.x = runner.x-29
across=across -1
elseif spritesurface1.keytest(&h7e) and grid (down-1,across)="1" then 'up key
runner.image=shuttleup
runner.y = runner.y-29
down=down -1
elseif spritesurface1.keytest(&h7d) and grid (down+1,across)="1" then 'down key
runner.image=shuttledown
runner.y = runner.y+29
down=down +1
End If
End If
'ChatProgress
If spritesurface1.keytest(49) then 'Space Key
ChatProgress = ChatProgress + 1
If ChatProgress = 2 then
ChatSprite.Image = IntroChat2
ElseIf ChatProgress = 3 then
ChatSprite.Image = IntroChat3
ElseIf ChatProgress = 4 then
ChatSprite.Image = IntroChat4
ElseIf ChatProgress = 5 then
ChatSprite.Image = IntroChat5
ElseIf ChatProgress = 6 then
ClearAll()
LevelProgress = 1
StatusText.Text="You are currently on Level:"+ Str(LevelProgress) +" of 8"
presid.stop
tank.playlooping
CheckLevel()
End If
End If
'ElementalBolt Animation
For i = 1 to 3
If LevelProgress >=3 then
If ElementalBolt(i)<>nil then
If ElementalBolt(i).x<=290 then
If i = 1 then
ElementalBolt(i).x = ElementalBolt(i).x+29'Travels to the right if reached x<=290
Elseif i=2 then
ElementalBolt(i).x = ElementalBolt(i).x+58'Travels to the right if reached x<=290
ElseIf i=3 then
ElementalBolt(i).x = ElementalBolt(i).x+43'Travels to the right if reached x<=290
End If
Elseif ElementalBolt(i).x >290 then
ElementalBolt(i).x=0
End If
End If
End If
Next

'Stationary Animations
If LevelProgress >= 5 then
If Asteroid.image=Asteroid1 then 'Asteroid Animation
Asteroid.image=Asteroid2
ElseIf Asteroid.image=Asteroid2 then
Asteroid.Image=Asteroid3
Elseif Asteroid.Image=Asteroid3 then
Asteroid.Image=Asteroid4
ElseIf Asteroid.image=Asteroid4 then
Asteroid.image=Asteroid1
End If
If LevelUp.image=Blackhole1 then 'Blackhole Animation
LevelUp.image=Blackhole2
Elseif LevelUp.image=Blackhole2 then
LevelUp.image = blackhole3
Elseif LevelUp.image =blackhole3 then
LevelUp.image = blackhole4
Elseif LevelUp.image=blackhole4 then
LevelUp.image=blackhole1
End If
If Block.Image=Blade1 then 'Blade Animation
Block.Image=Blade2
ElseIf Block.Image=Blade2 then
Block.Image=Blade3
ElseIf Block.image=blade3 then
Block.Image = Blade4
ElseIf Block.image = blade4 then
Block.Image = Blade1
End If
ElseIf LevelProgress = 4 then 'FireSprite Animation
If Block.Image=FireSprite1 then
Block.Image=FireSprite2
ElseIf block.image=Firesprite2 then
block.image=Firesprite3
ElseIF Block.Image=FireSprite3 then
Block.Image=FireSprite4
ElseIf Block.Image=FireSprite4 then
Block.Image=FireSprite1
End iF
End If
If SilverCoin<>Nil then 'SilverCoin Animation
If SilverCoin.Image=Coin1 then
SilverCoin.Image=Coin2
ElseIf SilverCoin.Image=Coin2 then
SilverCoin.Image=Coin3
ElseIf SilverCoin.Image=Coin3 then
SilverCoin.Image=Coin4
ElseIf SilverCoin.Image=Coin4 then
SilverCoin.Image=Coin5
ElseIf SilverCoin.Image=Coin5 then
SilverCoin.Image=Coin6
ElseIf SilverCoin.Image=Coin6 then
SilverCoin.Image=Coin7
ElseIf SilverCoin.Image=Coin7 then
SilverCoin.Image=Coin1
End iF
End if

Do any of you have any ideas on the problem?


Top
 Profile  
Reply with quote  
 Post subject: Re: SpriteSurface trailing
PostPosted: Thu Sep 10, 2009 8:46 pm 
Offline
User avatar

Joined: Thu Aug 06, 2009 2:25 pm
Posts: 261
Location: Oregon
I'm not entirely sure as it's been a long time since I've worked with Sprite Surfaces, but it seems that you aren't clearing the draw area before drawing the new frame.

_________________
AppleSource Software
http://www.applesource.biz


Top
 Profile  
Reply with quote  
 Post subject: Re: SpriteSurface trailing
PostPosted: Mon Sep 14, 2009 12:05 am 
Offline
User avatar

Joined: Sat Nov 11, 2006 2:43 pm
Posts: 1221
Location: This poster has left the forums
I have never used the sprite classes. They are depreciated now. No idea why RS did that.

Anyway, check out the example "pacMacOnMarsSource".
In NextFrame they call some redrawing, which you don't appear to do in your code example. The example should at least illustrate how to draw sprites properly.
dim i,u as integer
// give each sprite a chance to redraw itself
u = ubound(self.sprites)
for i = 1 to u
self.sprites(i).redraw(self)
next
// give our subclass a chance to redraw itself
redraw

_________________
%Invalidforumsignatureexception% user signature not found


Top
 Profile  
Reply with quote  
 Post subject: Re: SpriteSurface trailing
PostPosted: Mon Sep 14, 2009 12:26 am 
Offline
User avatar

Joined: Fri Sep 30, 2005 3:29 pm
Posts: 704
pony wrote:
I have never used the sprite classes. They are depreciated now. No idea why RS did that.


I think I remember people saying it wasn't very good and they recommended using this:
http://www.tinrocket.com/software/
http://www.tinrocket.com/software/superspritesurface/

_________________
Intel MacBook Pro OS X 10.5.7 RB Pro.


Top
 Profile  
Reply with quote  
 Post subject: Re: SpriteSurface trailing
PostPosted: Mon Sep 14, 2009 6:11 am 
Offline

Joined: Wed Sep 02, 2009 10:57 am
Posts: 2
Thanks for the help guys, while playing around with the program I added a MoviePlayer control and the trailing problem seemed to disappear for some odd reason.
I'll keep the redrawing and the other SpriteSurface option in mind if it reappears.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group