SCREEN_SCALE() function returns type of the screen.ricardobytes wrote:It would be appreciated if you could sense retina screens and adjust the size for them.
Space War
- Mr. Kibernetik
- Site Admin
- Posts: 4786
- Joined: Mon Nov 19, 2012 10:16 pm
- My devices: iPhone, iPad, MacBook
- Location: Russia
- Flag:
Re: Space War
- rbytes
- Posts: 1338
- Joined: Sun May 31, 2015 12:11 am
- My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet - Location: Calgary, Canada
- Flag:
- Contact:
Re: Space War
For now, I modified the third line under INICI: near the start of the code to
m(a,0)=RND(2047)!m(a,1)=RND(1535)
The screen is now filled with stars.
However, the shot trails are still appearing only in the top left corner, so that needs to be modified too. I haven't found that section of code yet.
The first two lines under MAIN: are both GOSUB CLEARCRAFT. One of them can be deleted with no effect.
I hope you will develop the one player against computer routine. My wife doesn't like computer games, and my dog has not yet learned how to play.
m(a,0)=RND(2047)!m(a,1)=RND(1535)
The screen is now filled with stars.
However, the shot trails are still appearing only in the top left corner, so that needs to be modified too. I haven't found that section of code yet.
The first two lines under MAIN: are both GOSUB CLEARCRAFT. One of them can be deleted with no effect.
I hope you will develop the one player against computer routine. My wife doesn't like computer games, and my dog has not yet learned how to play.
The only thing that gets me down is gravity...
- rbytes
- Posts: 1338
- Joined: Sun May 31, 2015 12:11 am
- My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet - Location: Calgary, Canada
- Flag:
- Contact:
Re: Space War
After some more experimenting, I decided to see how many hits a player needed to score to win. I set up a "shooting duck" situation with the two craft stationary and the red one aimed squarely at the blue. I fired over and over as fast as I could. I figured that when my red progress bar reached the right side of the screen I would be declared the winner. However once I got there, I fired another 20 shots without the game ending. So my suggestion would be to set a limit to end the game (eg when the bar gets to the right side of the screen) and have a big "winner effect" using the color of the winning spacecraft.
The only thing that gets me down is gravity...
Re: Space War
Hi,
Nice to get your post. You just encouraged me to review this old program. I expect to do that and will try on one player mode between Crhistma's and new year (see if I manage to find the time). Do you have any other suggestions for improvements?
The routine for the star field regenaration was weird, because at that stage of developement smart basic did not have graphic funtions to keep the background. So the field is initially generated and every frame it is partially regenerated (at end of the source). Nowadays it does not make sense, since it already have nice graphic funtions available for that.
Mr. Kibernetik: your direct modifications are of course wellcome
Nice to get your post. You just encouraged me to review this old program. I expect to do that and will try on one player mode between Crhistma's and new year (see if I manage to find the time). Do you have any other suggestions for improvements?
The routine for the star field regenaration was weird, because at that stage of developement smart basic did not have graphic funtions to keep the background. So the field is initially generated and every frame it is partially regenerated (at end of the source). Nowadays it does not make sense, since it already have nice graphic funtions available for that.
Mr. Kibernetik: your direct modifications are of course wellcome
Re: Space War
Ok, let's do that winner effect too... or you can do it yourself.
As for my new version, I will have to wait until I have holidays.
As for my new version, I will have to wait until I have holidays.
- Mr. Kibernetik
- Site Admin
- Posts: 4786
- Joined: Mon Nov 19, 2012 10:16 pm
- My devices: iPhone, iPad, MacBook
- Location: Russia
- Flag:
Re: Space War
Wilshusen, nice to know you continue to develop your software
- rbytes
- Posts: 1338
- Joined: Sun May 31, 2015 12:11 am
- My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet - Location: Calgary, Canada
- Flag:
- Contact:
Re: Space War
I like your use of pixel drawing to create the stars, as it gives twice the detail on the retina screens.
An alternative to declaring a winner when the progress bar crosses the screen would be to have a timer that stops the game after 5 or 10 minutes and declares the leading player the winner.
An alternative to declaring a winner when the progress bar crosses the screen would be to have a timer that stops the game after 5 or 10 minutes and declares the leading player the winner.
The only thing that gets me down is gravity...
Re: Space War
I will be pleased to exchange ideas, but I think e-mail will suit better for that. My e-mail is wilshusen@yahoo.com
Re: Space War
Спасибо я только учусь. Полезная утилита.MARK99 wrote:Если тебе нужно вот мой утелит, в smart BASIC.Tantrixx wrote:Mr.Kibernetik, что означает команда RESET TIMER в этой программе? Уже не первый раз попадается, sB выдаёт ошибку. В описании нигде не нашёл.
http://www.kibernetik.pro/forum/viewtop ... =21&t=1139
Re: Space War
skeleton of a new program, for security copy purposes before i update the application to work on space war
Code: Select all
graphics
refresh off
option angle degrees
dim x(16),y(16),ang(16),behave(16),bang(16),bcount(16),dbang(16),dbcount(16),kia(16)
dim xs(16),ys(16),dxs(16),dys(16),counts(16)
'Tank 1
fill color 0.2,0.3,0.5
fill rect 0,0 to 34,24
fill color 0.4,0.5,0.7
fill rect 10,5 to 24,19
fill rect 24,11 to 39,12
SPRITE 1 SCAN 0,0, 40,24
sprite 1 show
'Tank 2
fill color 0.5,0.3,0.2
fill rect 0+40,0 to 34+40,24
fill color 0.7,0.5,0.4
fill rect 10+40,5 to 24+40,19
fill rect 24+40,11 to 39+40,12
SPRITE 2 SCAN 40,0, 40,24
sprite 2 show
'Tank 3
fill color 0.5,0.5,0.5
fill rect 0+80,0 to 34+80,24
fill color 0.7,0.7,0.7
fill rect 10+80,5 to 24+80,19
fill rect 24+80,11 to 39+80,12
SPRITE 3 SCAN 80,0, 40,24
draw rect 80,0 to 39+80,24
sprite 3 show
'shot1
fill color 0.6,0.5,0.1
fill rect 0,0 to 5,5
fill color 1,0.8,0.2
fill rect 2,2 to 4,4
sprite 51 scan 0,0, 5,5
sprite 51 show
sprite 51 copy 52
sprite 52 show
'shot2
fill color 0.1,0.5,0.1
fill rect 0,0 to 5,5
fill color 0.2,1,0.2
fill rect 2,2 to 4,4
for a=53 to 66
sprite a scan 0,0, 5,5
sprite a show
next a
refresh
fill color 0.1,0.1,0.2
'fill rect 0,0 to 1024,700
Option sprite pos central
'controls
draw color 0.5,0.5,0.5
draw rect 1,100 to 150,400
draw line 1,185 to 150,185
draw line 1,315 to 150,315
draw line 76,185 to 76,315
draw rect 25,450 to 125,600
draw rect 900,100 to 1000,250
draw rect 875,600 to 1022,300
draw line 875,385 to 1022,385
draw line 875,515 to 1022,515
draw line 950,385 to 950,515
refresh
for a=4 to 15
SPRITE 3 copy a! sprite a begin! sprite a show
x(a)=rnd(700)+150! y(a)=rnd(200)! ang(a)=rnd(180)*2!sprite a begin!
sprite a at x(a),y(a) angle ang(a)! sprite a show
next a
'Controls
refresh on
REFRESH
x(1)=300!y(1)=600
x(2)=700!y(2)=600
MAINLOOP:
'controls
cx=0!v1=0!v2=0!f1=0!f2=0
for a = 0 to 9
cx = TOUCH_X (a)
if cx>0 and cx<150 then
cy=TOUCH_Y(a)
if cy>100 and cy<175 then a1=a1-2! if a1<0 then a1=a1+360
if cy>315 and cy<400 then a1=a1+2! if a1>360 then a1=a1-360
if cy>175 and cy<315 and cx>75 then v1=1
if cy>175 and cy<315 and cx<75 then v1=-1
if cy>450 and cy<600 then f1=1
x(1)=x(1)+2*v1*cos(a1)!y(1)=y(1)+2*v1*sin(a1)
endif
if cx>875 then
cy=TOUCH_Y(a)
if cy>515 and cy<600 then a2=a2-2! if a2<0 then a2=a2+360
if cy>300 and cy<385 then a2=a2+2! if a2>360 then a2=a2-360
if cy>385 and cy<515 and cx<950 then v2=1
if cy>385 and cy<515 and cx>950 then v2=-1
if cy>100 and cy<250 then f2=1
x(2)=x(2)+2*v2*cos(a2)!y(2)=y(2)+2*v2*sin(a2)
endif
next a
'shots
if f1=1 and counts(1)<1 then
counts(1)=150!xs(1)=x(1)!ys(1)=y(1)!dxs(1)=cos(a1)*6!dys(1)=sin(a1)*6
end if
if f2=1 and counts(2)<1 then
counts(2)=150!xs(2)=x(2)!ys(2)=y(2)!dxs(2)=cos(a2)*6!dys(2)=sin(a2)*6
end if
if counts(1)>0 then
for b=3 to 15
'c=sprites_collide(51,10)
if xs(1)<x(b)+20 and xs(1)>x(b)-20 and ys(1)<y(b)+20 and ys(1)>y(b)-20 and kia(b)=0 then
kia(b)=1
counts(1)=0
sprite b hide
b=15
end if
next b
end if
if counts(2)>0 then
for b=3 to 15
'c=sprites_collide(51,10)
if xs(2)<x(b)+20 and xs(2)>x(b)-20 and ys(2)<y(b)+20 and ys(2)>y(b)-20 and kia(b)=0 then
kia(b)=1
counts(1)=0
sprite b hide
b=15
end if
next b
end if
for a= 3 to 15
if xs(a)<x(1)+20 and xs(a)>x(1)-20 and ys(a)<y(1)+20 and ys(a)>y(1)-20 then y(1)=700
if xs(a)<x(2)+20 and xs(a)>x(2)-20 and ys(a)<y(2)+20 and ys(a)>y(2)-20 then y(2)=700
next a
for a = 3 to 15
if counts(a)<1 and rnd(100)<25 then
if x(a)=x(1) then x(a)=x(a)+1
tg=(y(1)-y(a))/(x(1)-x(a))
tg=atn(tg)
if tg>ang(a)-7 and tg<ang(a)+7 then
counts(a)=150! xs(a)=x(a)!ys(a)=y(a)!dxs(a)=cos(ang(a))*6!dys(a)=sin(ang(a))*6
end if
if x(a)=x(2) then x(a)=x(a)+2
tg=(y(2)-y(a))/(x(2)-x(a))
tg=atn(tg)
if tg>ang(a)-7 and tg<ang(a)+7 then
counts(a)=150! xs(a)=x(a)!ys(a)=y(a)!dxs(a)=cos(ang(a))*6!dys(a)=sin(ang(a))*6
end if
end if
next a
for a = 1 to 15
if counts(a)>0 then
counts(a)=counts(a)-1
'fill rect xs(a), ys(a) size 5
xs(a)=xs(a)+dxs(a)!ys(a)=ys(a)+dys(a)
z=50+a
sprite z at xs(a),ys(a)
end if
next a
'enemies
for a = 3 to 15
if kia(a)>0 then goto JUMP
r=0
if behave(a)=0 then r=rnd(4)+1
'behave 1=turn to a certain angle, do not move
' 2=turn and move
' 3=move only
' 4 not move
' 5 attack 1
' 6 attack 2
if r=1 then
behave(a)=1
bang(a)=rnd(180)*2
if bang(a)>ang(a) then dbang(a)=2
if bang(a)<ang(a) then dbang(a)=-2
endif
if r=2 then
behave(a)=2
bang(a)=rnd(180)*2
if bang(a)>ang(a) then dbang(a)=2
if bang(a)<ang(a) then dbang(a)=-2
bcount(a)=360
if 1=1 then dbcount(a)=2 else dbcount(a)=-1
endif
if r=3 then
behave(a)=3
bcount(a)=rnd(150)+10
if 1=1 then dbcount(a)=2 else dbcount(a)=-1
end if
if r=4 then
behave(a)=4
bcount(a)=rnd(150)! dbcount(a)=0
end if
'next a
'for a = 3 to 15
if behave(a)=1 or behave(a)=2 then
ang(a)=ang(a)+dbang(a)
if ang(a)>360 then ang(a)=0
if ang(a)<0 then ang(a)=360
if ang(a)>=bang(a) and dbang(a)>0 then behave(a)=0
if ang(a)<=bang(a) and dbang(a)<0 then behave(a)=0
endif
if behave(a)=2 or behave(a)=3 then
bcount(a)=bcount(a)-1
x(a)=x(a)+cos(ang(a))*dbcount(a)
y(a)=y(a)+sin(ang(a))*dbcount(a)
if bcount(a)<=0 then behave(a)=0
endif
if behave(a)=4 then
bcount(a)=bcount(a)-1
if bcount(a)=0 then behave(a)=0
endif
if y(a)<0 then
y(a)=2! ang(a)=ang(a)+180!behave(a)=0
end if
if y(a)>700 then
y(a)=698! ang(a)=ang(a)-180! behave(a)=0
end if
if x(a)<0 then
x(a)=2! behave(a)=0
end if
if x(a)>1024 then
x(a)=1022! behave(a)=0
end if
JUMP:
next a
refresh
SPRITE 1 AT x(1),y(1) angle a1
Sprite 2 at x(2),y(2) angle a2
for a=3 to 15
sprite a at x(a),y(a) angle ang(a)
next a
for b=1 to 10000!next b
go to MAINLOOP
REFRESH
SPRITE END