I have been working on a game lately. It is about the German invasion of London.You, as a anti-aircraft(AA) gunner, must shoot down every plane and give the city of London enough time to evacute its population of 8,173,941 people.(the number is the exact population of london as of the last census. If a plane gets past you, game over. If you run out of ammo, game over. If you give them enough time to evacuate everyone, you beat the game. And it is extremely accurate on the details. It takes place in WWII, during the invasion of London.

One problem that I have is.... How can I get more than one point(the german airplanes) to display and come towards me, without sacrificing too much speed? This is written in Basic, by the way.
I am working with C# and the way that we did that is to have a separate program that has all of the code for the enemies and have another program that calls them
Do you have a delay on the planes, so that they have a certain speed? Obviously doing rand() or something like that would slow it down, so the way you would have to do it is keep adding to a variable a certain number of times, and every Nth number you move a character. That way, you don't hinder the getKey response time when a user presses a key. You can also reset the variable, if you need to. If you need more of an explanation, perhaps you can look at my avalanche plus code.

Then again, I don't exactly know if this is the case. Could we maybe see your code so far?

honestly though, I would recommend hybrid basic or something if you don't want to sacrifice speed too much.
BASIC is not suited for the speed in graphics you need. Using text sprites for airplanes, a slower method, takes at least 40 milliseconds per sprite, and even more on the CSE. If we assume that you'll use an unrealistic 3/4 of your time drawing, moving, and erasing planes, and there are 6 sprites to draw per frame at 10 FPS, that leaves you only 13 ms per sprite. This is certainly not enough time to erase, calculate the next coordinate pair, and then redraw. Using combinations of Pt-On(,,2 and Pt-On(,,3, or a single character of text, can be faster, but it is very limited and you'll still struggle to get even five frames per second.
lirtosiast is right here, although I believe the speeds would be even slower for a CSE.
To test, I just made a simple game where you watch 5 Vs scroll down the screen, move around, and shoot/destroy the V. It terminates when you destroy them all. This is the fastest I was able to make it, and it's still really too slow to be enjoyable:

Code:

randIntNoRep(1,26,5->L1
13->C
While dim(L1
For(A,1,9
getKey
Output(10,C,"^
For(B,1,dim(L1
Output(A,L1(B),"V
If not(Ans
getKey
End
For(B,dim(L1),1,~1
Output(A,L1(B),"
If not(Ans
getKey
End
Output(10,C,"
Ans->[recursiven]
C-([recursiven]=24)+([recursiven]=26->C
If [recursiven]=21:Then
For(X,9,1,~1
Output(X,C,".
End
If max(C=L1:Then
1+sum(not(cumSum(L1=C
If 1<dim(L1:Then
seq(L1(Z+(Z>=Ans)),Z,1,dim(L1)-1->L1
Else
0->dim(L1
End
End
For(X,9,1,~1
Output(X,C,"
If rand
End
End
End
End

See how slow that is? I'd strongly recommend using hybrid Basic to do this.
Michael2_3B wrote:
Do you have a delay on the planes, so that they have a certain speed? Obviously doing rand() or something like that would slow it down, so the way you would have to do it is keep adding to a variable a certain number of times, and every Nth number you move a character. That way, you don't hinder the getKey response time when a user presses a key. You can also reset the variable, if you need to. If you need more of an explanation, perhaps you can look at my avalanche plus code.

Then again, I don't exactly know if this is the case. Could we maybe see your code so far?

honestly though, I would recommend hybrid basic or something if you don't want to sacrifice speed too much.


I do have a delay set in. Every time the point moves one, I have a Txt( command that tells you how many people are left in London. Without this, the program becomes so fast that the point zooms across the screen, making it impossible to shoot.

Some code:

Code:
ClrHome
Menu("AIM AND FIRE!","FIGHT",1,"RETREAT",2
Lbl 2
ClrHome
Output(1,1,"YOU HAVE ABANDONED ALL OF LONDON!!! NOOOOOOOO.....
Pause :ClrHome
Stop
End
Lbl 1
ClrDraw:0->B:0->C:0->A:randInt(~7,8)->D:~9->E:100->G:8173941->F:1->theta:1000->M:10->L1(1):0->L2(1)
Horizontal ~10
startTmr->H
Repeat A=45 or theta=0 or F=0 or G=0
checkTmr(H)->I
Text(1,1,"AMMO:",G," PEOPLE LEFT:",F,"     
getKey->A
If A=22:Then
Pause
End
F-1->F
B-(A=24)+(A=26+(B<=~9)-(B>=9)->B
C-(A=34)+(A=25)-(C>=9)+(C<=~9)->C
If G=25:Then
startTmr->J
End
checkTmr(J)->K
If K=15:Then
randInt(~5,5)->L:Pt-On(L,M
10->M
End
If B=L and C=M:Then
100->G:10->L:10->M
End
Pt-On(L,M,14
Pt-On(E,D,11
Pt-Off(E-1,D
Pt-On(8,~9.5,2
Pt-On(B,C,3
Pt-Off(B+1,C,3
Pt-Off(B-1,C,3
Pt-Off(B,C+1,3
Pt-Off(B,C-1,3
If I>=1:Then
E+1->E:M-1->M:startTmr->H
End
If E=9:Then
theta-1->theta
randInt(~7,8)->D:~9->E
End
If A=21:Then
Line(8,~9.5,B,C,12,1
Line(8,~9.5,B,C,20
G-1->G
If B=E and C=D:Then
Pt-Off(E,D):randInt(~7,8)->D:~9->E
End
End
End:ClrHome


Screenshots:

Well, if the point is already fast, then why are you asking for help with 'not sacrificing too much speed'? Just use a list to store positions like I did in the homescreen text game, do away with the Text command, and as long as you don't have more than about ten planes onscreen at any given time you'll be good.
Oh, I misunderstood. I thought you had sprites for planes, rather than single points. Maybe you can get away with using BASIC here after all.
Unfortunately, I can't do pt-On(L1,L2). That gives me a "data mismatch error".
You would need to loop through them all to display every coordinate, or you can set the lists as plots. I think that way's much faster.
caleb1997 wrote:
Unfortunately, I can't do pt-On(L1,L2). That gives me a "data mismatch error".


Er... no it doesn't. There are two errors that match with that, being 'Data type' and 'Dim mismatch', and I could see both being given in this case.
Check again; if it errors with 'Data type' then you'll have to do what Haobo said and loop through every list. Otherwise if it says 'dim mismatch', you'll have to check if L1 and L2 are the same size.

Edit: Didn't see the rest of haobo's post, but he's right: you should use stat plots, they're a lot faster.
If I do decide to use stat plots, I see a (possible) problem:
Won't the stat plots leave the points that they've already made there, and not erase them? If that is the case, then when the next bunch of points come along, they will be camoflaged. And how would I do a stat plot anyways? Just store the numbers to L1 and L2 and have plot1 set to L1 and L2? Also, how would I detect it if the point was shot down?
Never Mind! That isn't something to worry about..... Would you guys like the points to be red, or start at green, change to yellow, and then red as they get closer and closer to you? Also, would any of you guys like to have the planes shoot back at you?

Thanks for the stat plots tip, by the way, since it is a lot faster than doing points using variables.
  
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
Page 1 of 1
» 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