Okay, I've been trying to make a 3rd person shooter in BASIC. I've got it working so the guy can move around and shoot, but it runs extremely slow. I realize that BASIC is slow anyway, but I think most of this is my fault.

I have the program, a sub routine to move,one to shoot, and one for the moving target you shoot at all called in the program's main loop. Does calling a sub routine slow your program more than just trying to put it all in the same program? And I have it so you can only shoot one bullet at a time due to the lack of variables. Is using a list slower than just using variables?
I'm preety sure using lists is slower than using variables only. Subroutines might also contribute to the slowness. But remember it is BASIC. It can only get so quick...
foamy3 wrote:
Okay, I've been trying to make a 3rd person shooter in BASIC. I've got it working so the guy can move around and shoot, but it runs extremely slow. I realize that BASIC is slow anyway, but I think most of this is my fault.

I have the program, a sub routine to move,one to shoot, and one for the moving target you shoot at all called in the program's main loop. Does calling a sub routine slow your program more than just trying to put it all in the same program? And I have it so you can only shoot one bullet at a time. I think I could get more with a list instead of a variable, but would that slow it down even more?


by sub routines are just as fast as all in one program (they can be faster if it means you don't have to use a goto)

lists are slower than variables (by a noticeable amount)
Lists are slower indeed, but so little that it is normally not really making a difference. But, in my program, I found that using lists in programs that are constantly running is bad. Such as the program which controls movement; it is nearly always running, so using lists there would make it much slower (personal experience).

As for sub-programs, I do not believe it slows down generally, but certain things should be looked at:
Try to use Return as often as you can (meaning, do not call a program if you can just Return to it).
Avoid having 2 programs call each other over and over.

Keep in mind I'm an amatuer, so I hope someone better can correct me; but I think most of that is true! Razz

http://sc.cemetech.net

Load up the code and we can take a look at it!
I hardly have anything in the program and it is already almost unbearably slow. Should I just abandon it and learn asm?
dopeheaddude wrote:
Lists are slower indeed, but so little that it is normally not really making a difference. But, in my program, I found that using lists in programs that are constantly running is bad. Such as the program which controls movement; it is nearly always running, so using lists there would make it much slower (personal experience).


lists are drastically slower than a var

@Foamy: it'll always be slow, but if you paste the code(s), i'm sure people here can find optimizations you may be overlooking
Errr... Laughing
Rolling Eyes
They are indeed much slower. I agree with DHD - post up some code and let's see whatcha got.
dopeheaddude wrote:
Lists are slower indeed, but so little that it is normally not really making a difference. But, in my program, I found that using lists in programs that are constantly running is bad. Such as the program which controls movement; it is nearly always running, so using lists there would make it much slower (personal experience).

As for sub-programs, I do not believe it slows down generally, but certain things should be looked at:
Try to use Return as often as you can (meaning, do not call a program if you can just Return to it).
Avoid having 2 programs call each other over and over.

Keep in mind I'm an amatuer, so I hope someone better can correct me; but I think most of that is true! Razz

http://sc.cemetech.net

Load up the code and we can take a look at it!

You're an amateur? I don't know why but I thought you were more experienced... At least I know I'm not the only amateur around here.
There are always noobs, and there are always noobs becoming less noobly. Smile
Err, I'm amateur enough to be called amateur! Razz




Psst: Kerm, check your PMs; I'm dieing here!
So anyway, this kind of game can definitely be made to run at a decent speed, provided that it's well-optimized.
There's always room for improvement! Wink
dopeheaddude wrote:
There's always room for improvement! Wink

Improve this:

Code:
1-->A
dopeheaddude wrote:
There's always room for improvement! Wink

Yep. Someone needs to hear that if you know what I mean.
BASIC Code wrote:
:ClrDraw
:AxesOff
:RecallPic Pic1
:1W
:0R
:0J
:0I
:0
:5P
:1Q
:9A
:1B
:AN
:BO
:Pause
:ClrDraw
:prgmZMOVE
:0K
:Lbl A
:getKeyK
:If K=34
:A+2N
:If K=25
:A-2N
:If K=24
:B-2O
:If K=26
:B+2O
:
:If K=34 or K=24 or K=25 or K=26
:prgmZMOVE
:prgmZTARGET
:If K=21 and =0
:1
:If 0
:prgmZSHOOT
:
:If K=105
:Then
:ClrHome
:Stop
:End
:
:
:
Generated by SourceCoder, © 2005 Cemetech



thetazmove

BASIC Code wrote:
:Pxl-Off(A,B+1
:Pxl-Off(A+1,B
:Pxl-Off(A+1,B+2
:Pxl-Off(A+2,B+1
:Pxl-Off(A+3,B+1
:Pxl-Off(A+4,B+1
:Pxl-Off(A+4,B
:Pxl-Off(A+4,B+2
:Pxl-Off(A+5,B+1
:Pxl-Off(A+6,B+1
:Pxl-Off(A+7,B
:Pxl-Off(A+7,B+2
:
:If W=1
:Then
:Pxl-Off(A+4,B+3
:Pxl-Off(A+3,B+3
:Pxl-Off(A+3,B+4
:End
:If W=2
:Then
:Pxl-Off(A+4,B+3
:Pxl-Off(A+3,B+3
:Pxl-Off(A+3,B+4
:Pxl-Off(A+3,B+5
:End
:
:
:If N>0 and N<55
:NA
:If O>0 and O<75
:OB
:
:Pxl-On(A,B+1
:Pxl-On(A+1,B
:Pxl-On(A+1,B+2
:Pxl-On(A+2,B+1
:Pxl-On(A+3,B+1
:Pxl-On(A+4,B
:Pxl-On(A+4,B+1
:Pxl-On(A+4,B+2
:Pxl-On(A+5,B+1
:Pxl-On(A+6,B+1
:Pxl-On(A+7,B
:Pxl-On(A+7,B+2
:
:If W=1
:Then
:Pxl-On(A+4,B+3
:Pxl-On(A+3,B+3
:Pxl-On(A+3,B+4
:End
:If W=2
:Then
:Pxl-On(A+4,B+3
:Pxl-On(A+3,B+3
:Pxl-On(A+3,B+4
:Pxl-On(A+3,B+5
Generated by SourceCoder, © 2005 Cemetech



thetazshoot

BASIC Code wrote:
:If =1
:Then
:A+3I
:B+6J
:Pxl-On(I,J
:Pxl-On(I,J+1
:Pxl-On(I,J+2
:+1
:End
:If 1
:Then
:Pxl-Off(I,J
:Pxl-Off(I,J+1
:Pxl-Off(I,J+2
:J+2J
:
:If IP and IP+4
:Then
:If J+2=90 or J+1=90
:Then
:R+1R
:If B10 and W=2
:R+9R
:Text(50,45,R
:End
:If R=5
:Then
:For(Z,1,62
:Pxl-On(Z,10
:End
:2W
:End
:End
:
:
:Pxl-On(I,J
:Pxl-On(I,J+1
:Pxl-On(I,J+2
:+1
:End
:If J91
:Then
:0
:Pxl-Off(I,J
:Pxl-Off(I,J+1
:Pxl-Off(I,J+2
:End
:If =20 and W=1
:Then
:0
:Pxl-Off(I,J
:Pxl-Off(I,J+1
:Pxl-Off(I,J+2
Generated by SourceCoder, © 2005 Cemetech


thetaztarget

BASIC Code wrote:
:If P=3
:1Q
:If P=55
:2Q
:
:Pxl-Off(P,90
:Pxl-Off(P+1,90
:Pxl-Off(P+2,90
:Pxl-Off(P+3,90
:Pxl-Off(P+4,90
:
:If Q=1
Razz+1P
:If Q=2
Razz-1P
:
:Pxl-On(P,90
:Pxl-On(P+1,90
:Pxl-On(P+2,90
:Pxl-On(P+3,90
:Pxl-On(P+4,9
Generated by SourceCoder, © 2005 Cemetech
Jonathan_Pezzino wrote:
dopeheaddude wrote:
There's always room for improvement! Wink

Improve this:

Code:
1-->A


That's not a game! Wink Laughing
Crap, I have to get offline for about an hour. I'll be back, though. I promise.
These forums aren't moving anywhere. I'm preety sure it's better to just Delvar a variable instead of doing 0->Var.
something1990 wrote:
These forums aren't moving anywhere. I'm preety sure it's better to just Delvar a variable instead of doing 0->Var.


0->var is faster

delvar var takes less space

take your pick
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
» Goto page 1, 2, 3, 4, 5, 6  Next
» View previous topic :: View next topic  
Page 1 of 6
» 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
You cannot vote in polls in this forum

 

Advertisement