import serial
import time
ser = serial.Serial("COM35", 9600)
n = 127
while 1:
c = n
if c != 34 and c != 13:
c = chr(c)
ser.write(c.encode())
print(c)
n -= 1
if n < 33:
n = 127
time.sleep(0.1)
call IntensitySprite(80)
call SetFrameRate(60)
char_rcd = 0
notice = { _
{-70, 70, "1"}, _
{-70, 50, "2"}, _
{-70, 30, "3"}}
notes = { _
{22,102}, _
{21,36}, _
{19,244}, _
{18,213}, _
{17,199}, _
{16,199}, _
{15,214}, _
{14,243}, _
{14,28}, _
{13,81}, _
{12,146}, _
{11,221}, _
{11,51}, _
{10,146}, _
{9,250}, _
{9,107}, _
{8,227}, _
{8,100}, _
{7,235}, _
{7,121}, _
{7,14}, _
{6,169}, _
{6,73}, _
{5,239}, _
{5,153}, _
{5,73}, _
{4,253}, _
{4,181}, _
{4,114}, _
{4,50}, _
{3,246}, _
{3,189}, _
{3,135}, _
{3,84}, _
{3,36}, _
{2,247}, _
{2,205}, _
{2,164}, _
{2,126}, _
{2,91}, _
{2,57}, _
{2,25}, _
{1,251}, _
{1,222}, _
{1,195}, _
{1,170}, _
{1,146}, _
{1,124}, _
{1,102}, _
{1,82}, _
{1,63}, _
{1,45}, _
{1,28}, _
{1,12}, _
{0,253}, _
{0,239}, _
{0,226}, _
{0,213}, _
{0,201}, _
{0,190}, _
{0,179}, _
{0,169}, _
{0,160}, _
{0,151}, _
{0,142}, _
{0,134}, _
{0,127}, _
{0,120}, _
{0,113}, _
{0,107}, _
{0,101}, _
{0,95}, _
{0,90}, _
{0,85}, _
{0,80}, _
{0,75}, _
{0,71}, _
{0,67}, _
{0,63}, _
{0,60}, _
{0,56}, _
{0,53}, _
{0,50}, _
{0,47}, _
{0,45}, _
{0,42}, _
{0,40}, _
{0,38}, _
{0,36}, _
{0,34}, _
{0,32}, _
{0,30}, _
{0,28}, _
{0,27}, _
{0,25}, _
{0,24}, _
{0,22}, _
{0,21}, _
{0,20}, _
{0,19}, _
{0,18}, _
{0,17}, _
{0,16}, _
{0,15}, _
{0,14}, _
{0,13}, _
{0,13}, _
{0,12}, _
{0,11}, _
{0,11}, _
{0,10}, _
{0,9}, _
{0,9}, _
{0,8}, _
{0,8}, _
{0,7}, _
{0,7}, _
{0,7}, _
{0,6}, _
{0,6}}
cameraTrans = {0, 0, 0}
call CameraTranslate(cameraTrans)
call Randomize
call ScaleSprite(64, 324 / 0.097)
shipWidth = 7.0
shipHeight = shipWidth * 0.75
podDiameter = shipWidth * 5 / 8
ships = NewShip()
'crossDisplay = LinesSprite(crosshair)
sprite_mag = 4
play = false
print "done..."
frames = 0
vol = 0
c = 40
p = 30
char_rcd = 0
startframe = 0
arp = 0
while true
controls = WaitForFrame(JoystickNone, Controller1, JoystickNone)
for i = 1 to UBound(ships)
call SpriteRotate(ships[i, 1], 0.4, 0, 0)
next i
if UBound(ships) > 10 then
for i = 1 to UBound(ships)
call RemoveSprite(ships[i, 1])
next i
'call ClearScreen()
'cameraTrans = {0, 0, 0}
'call CameraTranslate(cameraTrans)
'call Randomize
'call ScaleSprite(64, 324 / 0.097)
ships = NewShip()
endif
'call SpriteRotate(triangleSprite, 1)
frames = frames + 1
if feof(Stdin) = false then
call ReturnToOriginSprite()
ships = AppendArrays(ships, NewShip())
'print "data!"
c = fgetc(Stdin)
command = false
if c = 34 or c = 13 then
command = true
endif
if c = 1 then
command = true
if arp = 1 then
arp = 0
else
arp = 1
endif
endif
if not command then
p = c - 30
endif
'xy[1,1] = xy[1,1] + 1
'info[1, 3] = "SCALE: " + p
char_rcd = char_rcd + 1
play = true
vol = 15
startframe = frames
endif
if controls[1, 4] then
print "play from joy", UBound(ships)
play = true
vol = 15
startframe = frames
endif
if play and vol > -1 then
if vol > -1 and (frames - startframe) mod 4 = 0 then
vol = vol - 1
endif
if frames - startframe = 1 then
'print "playing something!"
call Sound({{0, notes[p,2]}, {1, notes[p,1]}})
call Sound({{7, $3e}, {8, vol}})
if vol > 10 then
for i = 1 to UBound(ships)
call SpriteSetMagnification(ships[i, 1], p/10)
next i
sprite_mag = p/10
endif
endif
if frames - startframe = 2 then
arp_add = 0
if arp then
arp_add = 5
endif
call Sound({{0, notes[p+arp_add,2]}, {1, notes[p+arp_add,1]}})
call Sound({{7, $3e}, {8, vol}})
if vol > 10 then
for i = 1 to UBound(ships)
call SpriteSetMagnification(ships[i, 1], (p+arp_add)/10)
next i
sprite_mag =(p+arp_add)/10
endif
endif
if frames - startframe = 3 then
arp_add = 0
if arp then
arp_add = 10
endif
call Sound({{0, notes[p+arp_add,2]}, {1, notes[p+arp_add,1]}})
call Sound({{7, $3e}, {8, vol}})
if vol > 10 then
for i = 1 to UBound(ships)
call SpriteSetMagnification(ships[i, 1], (p+arp_add)/10)
next i
sprite_mag =(p+arp_add)/10
endif
endif
if frames - startframe = 4 then
startframe = frames
endif
endif
if sprite_mag > 1 or sprite_mag < 1 then
if sprite_mag > 4 then
sprite_mag = sprite_mag - 0.1
endif
if sprite_mag < 4 then
sprite_mag = sprite_mag + 0.1
endif
for i = 1 to UBound(ships)
call SpriteSetMagnification(ships[i, 1], sprite_mag)
next i
endif
'if controls[1, 6] then
' stop
'endif
endwhile
function TieFighter(shipWidth, shipHeight, podDiameter, wingSides, podSides)
tie = { _
{ MoveTo, -10,-10,10},_
{ DrawTo, 10,-10,10},_
{ DrawTo, 10,10,10}, _
{ DrawTo, -10,10,10}, _
{ DrawTo, -10,-10,10}, _
{ DrawTo, -10,-10,-10}, _
{ DrawTo, 10,-10,-10},_
{ DrawTo, 10,10,-10}, _
{ DrawTo, -10,10,-10}, _
{ DrawTo, -10,-10,-10}, _
{ MoveTo, 10,10,10}, _
{ DrawTo, 10,10,-10}, _
{ MoveTo, -10,10,-10}, _
{ DrawTo, -10,10,10}, _
{ MoveTo, 10,-10,-10}, _
{ DrawTo, 10,-10,10} _
}
return tie
endfunction
function NewShip()
dim ship[1, 2]
ship[1, 1] = Lines3DSprite(TieFighter(shipWidth, shipHeight, podDiameter, 6, 8))
' Choose a distance from us between 150 and 300 meters
z = rand() mod 150 + 150
' Choose an apparent position on the screen in meters (the screen is
' about 0.15 meters by 0.18 meters)
x = (rand() mod (150 - shipWidth) - 75) / 1000.0
y = (rand() mod (180 - shipHeight) - 90) / 1000.0
' Scale the apparent position on the screen to an actual translation based on
' the ship's z distance (and assuming the user sits 0.5 meters from the screen)
x = x / 0.5 * (z + 0.5)
y = y / 0.5 * (z + 0.5)
ship[1, 2] = {x, y, z}
call SpriteTranslate(ship[1, 1], ship[1, 2])
' Set the rotation of the ship
call SpriteRotate(ship[1, 1], rand() mod 360, rand() mod 360, rand() mod 360)
return ship
endfunction