Posted: 19th Oct 2013 19:35
Hello.
I was surfing the net a while ago and came accross the old "star Trek" game from the 70's here and thought I would make this for the Android platform (there already is a V good version for Android available).

I checked some old books for code and decided on a version from the 1981 book "64 Explosive Games for the ZX81".

Now converting ZX81 BASIC to DBpro was a learning experience and my results are very messy code, but I tried to follow the ZX81 code flow so as to get the idea of how the program runs.

Anyway it worked, its buggy and is ripe for improvement, I cant stop messing with it and have already added images and sounds as well as a colour energy bar.

So before I continue to tinker with it I thought I would offer the code up here so others can mess with it.

I have attached the media folder to this post. Thanks must go to IBOL for the alien head making code.

Here is a video of gameplay.


The game window should be 800X600
The quadrant display should not show the enemy position, I just had them showing for development purposes.
Here is the code: (media attached to post)
+ Code Snippet
Rem Project: startrek
Rem Created: Thursday, October 10, 2013

load sound "media/error.wav",1
load sound "media/phasor.wav",2
screencolour = rgb(0, 0, 0) // black
_start:
gosub _9000
gosub _8000
_loop:
gosub _7000
gosub _6950
gosub _7500

print "what is your order Captain ?"
set cursor 360,55
print "1: Scan"
set cursor 360,70
print "2: Move"
set cursor 360,85
print "3: Fire"
_entercommand:
set cursor 360,100
print "Enter Command: ";
input d
if d<1 OR d>3
    play sound 1
    box 478, 100, 700, 120, screencolour, screencolour, screencolour, screencolour
    goto _entercommand
endif
if d=1 then gosub _1000
if d=2 then gosub _2000
if d=3 then gosub _3000
goto _loop
end

REM Scan
_1000:
gosub _6950
set cursor 360,5
print "++++SCANNER++++"
gosub _7500
print "Short or Long range scan sir?";
set cursor 360,55
print "1: Short"
set cursor 360,70
print "2: Long"
set cursor 360,95
print "Scan Range: ";
input k
if k<1 OR k>2
    play sound 1
    set cursor 470,100 
    box 478, 100, 700, 120, screencolour, screencolour, screencolour, screencolour
    goto _1000
endif
e#=e#-10*k
gosub _7000
gosub _6950
if k=2 then goto _1500
if A(b+1,c)=1 OR A(b+1,c+1)=1 OR A(b,c+1)=1 OR A(b-1,c)=1 OR A(b-1,c-1)=1 OR A(b,c-1)=1 OR A(b+1,c-1)=1 OR A(b-1,c+1)=1
    set cursor 360,5
    print "++++SHORT RANGE SCANNER++++"
    gosub _7500
    print z$;
    print " in the vicinity sir !"
    paste sprite 1,350,70
    set cursor 424,90
    print z$
    paste sprite 1,350,70
    set cursor 424,90
    print z$
    wait key
    return
ENDIF
set cursor 360,5
print "++++SHORT RANGE SCANNER++++"
gosub _7500
print "Nothing in the vicinity sir !"
wait key
return

REM Long range scan
_1500:
gosub _6950
set cursor 360,5
print "++++LONG RANGE SCANNER++++"
gosub _7500
print "What direction to scan sir?";
set cursor 360,55
print "1: North"
set cursor 360,70
print "2: South"
set cursor 360,85
print "3: East";
set cursor 360,100
print "4: West";
set cursor 360,120
print "Enter scan direction vector: ";
input n
if n<1 OR n>4
    play sound 1
    set cursor 470,100 
    box 478, 100, 700, 120, screencolour, screencolour, screencolour, screencolour
    goto _1500
endif
z=0
if n=1 and A(b-2,c)=1 then z=1
if n=2 and A(b+2,c)=1 then z=1
if n=3 and A(b,c+2)=1 then z=1
if n=4 and A(b,c-2)=1 then z=1
gosub _6950
set cursor 360,5
print "++++LONG RANGE SCANNER++++"
gosub _7500
print "Long range scanner report is: ";
if z=1
    print "positive."
    paste sprite 1,350,70
    set cursor 424,90
    print z$
ENDIF

if z=0 then print "negative."
wait key
return

REM Move
_2000:
e#=e#-50
gosub _7000
A(b,c)=0
B(b,c)=0
gosub _6950
set cursor 360,5
print "++++SHIP MANEUVER++++"
gosub _7500
print "Which direction: ";
set cursor 360,55
print "N: North"
set cursor 360,70
print "S: South"
set cursor 360,85
print "E: East";
set cursor 360,100
print "W: West";
set cursor 360,120
print "Enter impulse direction: ";
input a$
if a$="S" or a$="s" and b<10 then b=b+1
if a$="N" or a$="n" and b>0 then b=b-1
if a$="E" or a$="e" and c<10 then c=c+1
if a$="W" or a$="w" and c>0 then c=c-1
// need to add routine if other input is entered
gosub _6950
set cursor 360,5
print "++++SHIP MANEUVER++++"
gosub _7500
print "ships position now at ";b;",";c
if A(b,c)=1 then goto _5500
A(b,c)=2
B(b,c)=2
gosub _8000
return

REM Fire
_3000:
gosub _6950
set cursor 360,5
print "++++PHASOR FIRE++++"
gosub _7500
print "Direction of fire sir"
set cursor 360,55
print "N: North"
set cursor 360,70
print "S: South"
set cursor 360,85
print "E: East";
set cursor 360,100
print "W: West";
set cursor 360,120
print "Enter phasor direction: ";
input a$
play sound 2
g=b
f=c
if a$="S" or a$="s" and b<10 then g=g+1
if a$="N" or a$="n" and b>0 then g=g-1
if a$="E" or a$="e" and c<10 then f=f+1
if a$="W" or a$="w" and c>0 then f=f-1
// need to add routine if other input is entered
e#=e#-100
if A(g,f)<>1 then goto _3300
gosub _6950
set cursor 360,5
print "++++PHASOR FIRE++++"
gosub _7500
print "Enemy "+z$+" ship hit !!"
ah=ah+1
B(g,f)=4
e#=e#+75 // gain 75 energy for a hit
if ah = al then goto _WIN
// A(g,f)=4
gosub _8000
wait key
return
_3300:
gosub _6950
set cursor 360,5
print "++++PHASOR FIRE++++"
gosub _7500
B(g,f)=3
print "You missed, sir "
// play scan sound
wait 1000
// stop scan sound
gosub _6950
set cursor 360,5
print "++++PHASOR FIRE++++"
gosub _7500
B(g,f)=3
print "The "+z$+" are returning fire..."
wait 1000
gosub _6950
randomize timer()
r#=RND(1000)
r#=r#/1000.0 // generate random number between 0 and 1
if r# > 0.6 then goto _3400
print "They hit us, sir..."
gosub _8000
e#=e#-rnd(100)
wait key
return
_3400:
gosub _6950
set cursor 360,5
print "++++PHASOR FIRE++++"
gosub _7500
print "The "+z$+" missed..."
wait 1000
return

REM Game over
_3800:
cls
gosub _6950
set cursor 0,0
print " Energy banks exhausted"
print " You killed ",ah," ",z$," out of ",al
print " Your commander rating is ",(al/B)*100
wait key
end

REM landed on alien ship
_5500:
cls
set cursor 15,15
print "The ship has landed on a ",z$," vessel";
goto _5500
end

REM print empty space draw black box over text
_6950:
set cursor 310,0
box 300, 0, 800, 200, screencolour, screencolour, screencolour, screencolour
return

REM status
_7000:
box 0, 210, 425, 830, screencolour, screencolour,screencolour, screencolour
set cursor 14,225
print "Energy Bank "
box 110, 229, 110+int((e#/ec#)*200), 237, RGB(255,0,0),RGB(255,0,0),RGB(0,255,0),RGB(0,255,0)
if e#<1 then goto _3800
set cursor 14,243
print "Aliens hit so far : ",ah,"/",al

set cursor 14,261
print "Ship location : ",b,",",c
set cursor 14,279
gosub _8500
print "In the "; : ink rgb(113,242,0),rgb(0,0,0): print sec$; : ink rgb(255,255,255),rgb(0,0,0) : print " sector"
return

REM choose crew member who speaks
_7500:
set cursor 360,28
randomize timer() // creates a better random number seed
r=rnd(4)
if r = 0 then print "Spock: ";
if r = 1 then print "Scott: ";
if r = 2 then print "Lt.Uhura: ";
if r = 3 then print "Chekov: ";
if r = 4 then print "Sulu: ";
return

Rem print out sector
_8000:
box 0, 0, 300, 190, screencolour, screencolour,screencolour, screencolour
 // top row of numbers 1 to 10
xpos=50
for zx=1 to 10
    set cursor xpos,25
    print zx
    xpos=xpos+25
NEXT zx

 // Next row
for q=14 to 140 step 14 // y position of next row
set cursor 18,q+25
print q/14 // 1 to 10
xpos=50
for p=1 to 10 // fill in the row    
    set cursor xpos,q+25
    if B(q/14,p)=0 then print "*"
    if B(q/14,p)=1 then print "E" // show aliens
    if B(q/14,p)=2 then print "$"
    if B(q/14,p)=3 then print "#"
    if B(q/14,p)=4 then print "+"
    xpos=xpos+25
next p // end of row
next q
 // bottom row of numbers 1 to 10
xpos=50
for zx=1 to 10
    set cursor xpos,q+25
    print zx
    xpos=xpos+25
NEXT zx
return

REM Sector
_8500:
q=b*c
if q<10 then sec$= "Antare"
if q>9 and q<20 then sec$= "Rigel"
if q>19 and q<30 then sec$= "Procyon"
if q>29 and q<40 then sec$= "Vega"
if q>39 and q<50 then sec$= "Canopus"
if q>49 and q<60 then sec$= "Altair"
if q>59 and q<70 then sec$= "Saggitarius"
if q>69 and q<80 then sec$= "Pollux"
if q>79 and q<90 then sec$= "Syrius"
if q>89 then sec$= "Betelgeus"
return

REM fill arrays and choose alien
_9000:
dim A(10,10)
dim B(10,10)
for a=1 to rnd(10)+10 // choose random number of aliens
    x=rnd(9)+1
    y=rnd(9)+1
    A(x,y)=1
    B(x,y)=1 // put aliens in B array so they show on the grid
    al=a // number of aliens
NEXT a
b=5
c=5
A(b,c)=2
B(b,c)=2
ah = 0 // aliens hit
randomize timer() // creates a better random number seed
e#=rnd(9)

if e#<=3
z$="BRARKONS"
load image "media/brarkons.png",1
EndIf

if e#>3 AND e#<=6
z$="WRERKTONIANS"
load image "media/wrerktonians.png",1
EndIf

if e#>6
z$="POLLUXIANS"
load image "media/polluxians.png",1
EndIf
sprite 1,100,100,1
set sprite 1,0,1
hide sprite 1
randomize timer()
r#=RND(1000)
r#=r#/1000.0 // generate random number between 0 and 1
e#=1000.0+(2000.0*r#)
ec#=e# // for nrg bar calculation
return

REM Win game when all aliens destroyed
_WIN:
cls
Print "You Won"
wait key
goto _start
Posted: 16th Nov 2013 23:34
There was something like this sold for the TRS-80. It may have been called "Trek80" although I don't recall. All I know was that it was a machine language program and actually had a little arcade action. You could actually see klingons shooting asterisks at star bases and you had to move in, guess an angle and fire. The you could zoom out to a long range scanner and jump to any of 100 sectors and of which might contain a hoard of klingons. It was a lot of fun.
Posted: 2nd Jan 2014 15:15
Sounds similar to this game but with added excitement