forums

TNT Basic Forums > Programming Q&A
I'm creating a side scrolling space shooter.. need tips
< Last Thread     Next Thread >
Author
Thread        Post A Reply

01-25-2002 08:23

Posted by:
Jason Anderson

Click Here to Email Jason Anderson   Find more posts by Jason Anderson

To prepare, I have been modifying the Outside Scrolling Map example. (The one with the trees and birds)

So far I have cut the birds to 10 (Instead of 30), made the map 15 tiles high and 100 wide (To make it more like an "R-Type" like game), fixed the controls to work in OS X, made it run at 60 instead of 30.

Some stuff like that.

I have set it to scroll right by itself.

But why is it so slow?

The game shows 20 FPS while moving and 60 when done scrolling. The birds move slow when the map is movine but as soon as the map stops they speed back up.

How will this affect my game when I plan on having many enemies at one time all on the map from the beginning as you scroll along. And many more sprites will be non enemies. So that makes maybe hundreds of sprites in each map. Though, only a few will be on screen at once.

Of course, I'd make it so the enemies wouldn't start moving or shooting until the viewport moves near them and if they fly far enough off screen they'd stop. Like those "R-Type" type games.

But the way I see it, the sprites will make the game run extremely slow. And it won't be full speed until the map has scrolled to the Boss at the end of the level.

If I can't make the game go fast enough, I may just have to change to a "Cybernoid" engine instead.

(R-Type used a one map scroll from left to right long map type level engine. Cybernoid used multiple maps which you flew through shooting enemies. Each screen was another map. All together they made up one big level.)

01-25-2002 10:27

Posted by:
Mark Tully

Find more posts by Mark Tully

Speed issues

The main problem is the amount of data that needs to be shifted around when the map scrolls. You're talking about recompositing the entire screen and then copying it to the screen, sprites don't help either. But we'll look into our map rendering and see if we can get scrolling going faster, as we've had a few complaints!

Cheers

Mark

01-25-2002 16:07

Posted by:
ChrisD

Find more posts by ChrisD

What machine and at what bit depth
were you getting 20 FPS on?

01-25-2002 21:21

Posted by:
Jason Anderson

Click Here to Email Jason Anderson   Find more posts by Jason Anderson

iMac 450MHz

640x480

01-25-2002 21:43

Posted by:
ERaZer

Find more posts by ERaZer

Weird...

That is very weird, on my g3 300 mhz I get solid 30 fps when I use the outdoor scrolling example and make it 60 birds and 1200*1600(This is more of a memory issue, I know)...
Could you show us some code?

01-25-2002 21:45

Posted by:
ERaZer

Find more posts by ERaZer

I meant...

I meant tiles, not resolution...

01-25-2002 23:03

Posted by:
Jason Anderson

Click Here to Email Jason Anderson   Find more posts by Jason Anderson

Tiles?

100 by 15

Or 40 by 15 on screen at a time.

Each tile is 32x32

01-25-2002 23:07

Posted by:
Jason Anderson

Click Here to Email Jason Anderson   Find more posts by Jason Anderson

Code

This is the Outdoor Scrolling Example edited by me.

The tiles are changed though. Make the map 100x15 and this should work.

'_____________________________

Global int kBirds=30
Global Int mapHeight = 15*32
Global Int mapWidth = 100*32


Global float x[kBirds],y[kBirds],xVel[kBirds],yVel[kBirds],image[kBirds],upImage[kBirds]

' Set up the screen
Hide Mouse
Fade Down
Graphics Mode 640,480
Vbl Sync On
Set Framerate 60
Open Canvas 1,mapWidth,mapHeight
Open Viewport 1,0,0 to 640,480

' Load data
Load Map 128
Load Images 128
Load Input 128

' Draw the scrolled area
Canvas 1
Draw Map Section 0,0 to 100,15,0 to 0,0

int n,xTemp,yTemp,animate=false
Set Sprite Transparency 0,50
Set Sprite Colour 0,0

'for n=0 to 30
'
' xTemp=Random(10,mapWidth)
' yTemp=yTemp+Random(5,64)
'
' Set Image Bank 0,128
' Sprite 0,xTemp,yTemp,1
' Paste Sprite 0
' Paste Image xTemp,yTemp,0,128
'
'next n

Sprite Off 0

for n=0 to kBirds-1

x[n]=Random(0,mapWidth)
y[n]=Random(0,mapHeight)

xVel[n]=Random(-100,100)/100
yVel[n]=Random(-100,100)/100

image[n]=Random(2,6)
upImage[n]=false

Set Image Bank n,128
Sprite n,x[n],y[n],image[n]

next n

' Prepare the screen for fade up
Draw Frame
Fade Up

int done=false
float xView=0,yView=0

Activate Input

while not done

if Poll Input(2)
done=true
end if

' Move the birds around
for n=0 to kBirds-1

x[n]=x[n]+xVel[n]
y[n]=y[n]+yVel[n]

if x[n]<-10
x[n]=mapWidth
else if x[n]>mapWidth
x[n]=-10
end if

if y[n]<-10
y[n]=mapHeight
else if y[n]>mapHeight
y[n]=-10
end if

if animate
if upImage[n]
image[n]=image[n]+1
else
image[n]=image[n]-1
end if
end if

if image[n]>6
image[n]=5
upImage[n]=false
else if image[n]<2
image[n]=3
upImage[n]=true
end if

Sprite n,x[n],y[n],image[n]

next n
animate=not animate

' Move the screen around
'yView=yView-1'Poll Input(1)/10
'xView=xView+1'Poll Input(0)/10

If Left then xView = xView - 5
'If Right then
xView = xView + 5

If Up then yView = yView - 5
If Down then yView = yView + 5

if (xView<0)
xView=0
else if (xView>mapWidth-Viewport Width(1))
xView=mapWidth-Viewport Width(1)
end if

if (yView<0)
yView=0
else if (yView>mapHeight-Viewport Height(1))
yView=mapHeight-Viewport Height(1)
end if

set viewport offset 1,xView,yView

Draw Frame
wend

Deactivate Input

Close Viewport 1

' Clean up
Fade Down
Text Mode
Fade Up
Show Mouse

01-26-2002 06:17

Posted by:
Jason Anderson

Click Here to Email Jason Anderson   Find more posts by Jason Anderson

Well, the project is coming along great! I have successfully made it into a side scrolling (Auto) map with a sprite pretending to be the "Ship" which moves with the level and stops when the map does, but still allows you to move in any direction.

But the SLOWNESS is terrible! I have deleted the birds and I still only get 30 frames while scrolling. 60 when stopped.

That scrolling example looks NOTHING like it did before. But at least it's helping me learn.

Next step I add enemies with collision and next ground and ceiling collision detection. Then weapons.

Then when the prototype is done, I can start over with a new project and make the final game with real graphics and everything.

If I hadn't just posted my older code above, I'd post the new code here. It's LONG.

Too bad we can't delete posts.

01-26-2002 06:24

Posted by:
Jason Anderson

Click Here to Email Jason Anderson   Find more posts by Jason Anderson

And now that I set it to Frame Rate Max, I ger 120 FPS when stopped. Still only 20-30 while scrolling.

Hope this gets sped up soon.

01-26-2002 14:25

Posted by:
ERaZer

Find more posts by ERaZer

Hmm..

On the g3 300 mhz I get(Without changing your code):
32 fps when scrolling(pretty solid 32 too)
60-70 fps when stopped(But framerate max is 60)
When I take off vbl sync I get:
40 fps when scrolling(pretty solid)
60 fps when stopped.
Did you use a iMac 450 mhz?
If so, its weird that the g3 300 mhz went faster...

01-27-2002 09:06

Posted by:
Jason Anderson

Click Here to Email Jason Anderson   Find more posts by Jason Anderson

Yes. It's 450MHz.

Are you in OS X?

I'd really like the speed to be the same at 60 FPS when scrolling. That'd be nice.

It just puts a few restrictions on my game.

Tomorrow I will test in OS 9 and see how it performs there.

01-28-2002 03:16

Posted by:
Jason Anderson

Click Here to Email Jason Anderson   Find more posts by Jason Anderson

In OS 9 I get 30-40 FPS while scrolling. 60 when stopped. (When the Frame Rate is set to 60)

When the FrameRate is set to Max I get 110 in 9.

There's a Speed problem which I hope gets fixed soon.

01-28-2002 08:46

Posted by:
Mark Tully

Find more posts by Mark Tully

Speed/Scrolling

Speed under X is a bit poor at present, but at least you always get a nice surprise when you boot into 9 :)

1.02 speeds up TNT Basic under OS X a bit, but I'm not sure how much of an increase will be in the final release, it should definitely be a 'bit' faster at least.

As for scrolling, we'll look into speeding it up.

Mark

01-29-2002 06:35

Posted by:
Jason Anderson

Click Here to Email Jason Anderson   Find more posts by Jason Anderson

Well. The human eye can see 66 FPS. So there's your goal! ;-)

01-29-2002 12:55

Posted by:
Ari Feldman

Click Here to Email Ari Feldman   Find more posts by Ari Feldman

Animation Speeds - FYI

The average human eye can percieve animation in as little as 12 FPS, so a game that runs evenly at 20 or 30FPS is quite ok for most purposes.

01-29-2002 14:02

Posted by:
ERaZer

Find more posts by ERaZer

Movies usually have 24 fps, right?

BTW, I'm going for solid 30 fps in my game so it will be playable on all g3's. And if they speed up TNTBasic it will run good on older computers as well.

01-29-2002 14:57

Posted by:
Mark Tully

Find more posts by Mark Tully

TNT Basic 1.02 speed boosts

Hi all,

The draw map command has just been speedboosted by an average of about %50.

Framerates on OS X have been vastly improved, but they still aren't as good as OS 9's.

We might never get TB running as fast under X as under 9, but I hope we should be able to get most of the way there.

I've got some more tricks to try, but they can wait for a future version. Expect TNT Basic 1.02 in the next few days!

Mark

01-29-2002 17:11

Posted by:
ERaZer

Find more posts by ERaZer

G00d

Cool, any speed boost is apprici8ed

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.