The Game Creators
The Game Creators Home Online Shop Click to Login
  Hot: Christmas CompetitionNovember NewsletterModel Pack 36DB Pro Pack 2009DGS BonanzaCharacter PackFPS Creator Bonanza;
The Game Creators
20 Liners / 50 liner - ships - 3D space conquest

Go to the first page of this board Return to the Forum Menu Post Message
14 Messages - Page   of 1   
Bookmark and Share Search the Forum

Author Message
Azrael

User


Joined: Wed Mar 2nd 2005
Location: Germany
Posted: 26th Mar 2007 07:26           | link | toggle

Hi everyone!

This is my contribution to the 50 line competition.

It's a space conquest game. You are player RED and you have to conquer planets which are producing ships for your fleet depending on each planets size.
You can send your fleets to enemy planets to fight them or to your own planets to support them. Click the mouse to select your planets. You can select more then one planet. At the moment you only can send the half of the planets fleet.

Try to conquer the all planets as fast as possible.

OK.. here's the Code:

compressed:

+ Code Snippet
set display mode 1024, 768, 32 : Sync on  :  Sync rate 0  :  Sync : Disable escapekey : Color backdrop 0x252525 : Set text font "Tahoma"
Type tship  px As Float :  py As Float :  pz As Float :  tx As Float :  ty As Float :  tz As Float :  dx As Float :  dy As Float :  dz As Float :  aim As Integer :  from As Integer :  size As Integer :  troops As Integer Endtype
Type tplanet  size As Integer :  fleet As Integer :  owner As integer Endtype
Cls : Input "How many opponents? (1 - 5) default 5 :", players : Input "How many planets? (min. " + str$( players + 2 ) + ") default 20 : ", maxplanets : Input "Difficulty? (easy: 30  hard: 300) default 100 : ", difficulty
If players = 0 : players = 5 : Endif : If difficulty = 0 : difficulty = 100 : Endif : If maxplanets = 0 : maxplanets = 20 : Endif : Inc players : If players > 6 : players = 6 : Endif : If players <= 1 : players = 2 : Endif : If maxplanets <= players : maxplanets = players + 1 : Endif : If maxplanets > 100 : maxplanets = 100 : Endif : If difficulty < 30 : difficulty = 30 : Endif : If difficulty > 300 : difficulty = 300 : Endif
Dim Planets( 100 ) As tplanet : Dim selplanets( -1 ) As Integer : Dim ships( -1 ) As tship : Dim player( 6 ) As Dword : null = Make matrix4( 1 ) : null = Make matrix4( 2 ) : null = Make matrix4( 3 ) : null = Make vector3( 4 ) : For i = 1 To 6 :  Read player( i ) : Next : Make light 1 : Set light range 1, 100000 : Ink 0x252525, 0x252525 : Box 0, 0, Screen width(), 30 : Ink 0xffffff, 0xffffff : set text size 20 : Center text 500, 1, "ships v1.0" :  Line 0, 29, Screen width(), 29 : get image 1, 0, 0, Screen width(), 30, 3 : Set text size 12 : CreatePlanets( maxplanets, players ) : d = 800  :  troops = 0  :  KItime = Timer()  :  gametime = timer() : game = 0
Do :  Set cursor 0, 35 :  mmx = Mousemovex() :  mmy = Mousemovey() :  mmz = Mousemovez() :  mx = Mousex() :  my = Mousey() :  po = Pick object( mx, my, 1, maxplanets ) :  If Timer() - lt > 1000 :  For i = 1 To maxplanets :  If Planets( i ).owner > 0 :  Inc Planets( i ).fleet, Planets( i ).size*.1 :  Endif :  Next :  lt = timer() :  Endif :  If timer() - KItime > 330 - difficulty
For i = 1 To maxplanets : If Planets( i ).owner > 0 And Planets( i ).owner <> player( 1 ) :  c = Planets( i ).owner :  For j = 1 To maxplanets :  If Rnd( 300 ) = 1 And i <> j :  If Planets( j ).owner = c :  If Planets(j).fleet > Planets(i).fleet :  SendShips( i, j, Planets( i ).fleet/2 ) :  Planets( i ).fleet = Planets( i ).fleet/2 :  Endif :  Else :  If Rnd( 10 ) = 1 :  SendShips( i, j, Planets( i ).fleet/2 ) :  Planets( i ).fleet = Planets( i ).fleet/2 :  Endif :  Endif :  Endif :  If Planets( j ).owner = 0 And Rnd( 20 ) > 2 :  If Rnd( 10 ) > 1
If Planets( i ).fleet > 40 And Planets( j ).fleet > 0 :  If Planets( i ).fleet/Planets( j ).fleet > 1.5 And Rnd( 5000 ) > Planets( j ).size :  SendShips( i, j, Planets( i ).fleet/2 ) :  Planets( i ).fleet = Planets( i ).fleet/2 :  Endif :  Endif :  Endif
 Else :  If c <> Planets( j ).owner :  If Planets( i ).fleet > 40 And Planets( j ).fleet > 0 :  If Planets( i ).fleet/Planets( j ).fleet > 1.5 And Rnd( 5000 ) > Planets( j ).size :  SendShips( i, j, Planets( i ).fleet/2 ) :  Planets( i ).fleet = Planets( i ).fleet/2 :  Endif :  Endif :  Endif :  Endif :  Next :  Endif :  Next :  KItime = timer() :  Endif :  Projection matrix4 1 :  View matrix4 2 :  World matrix4 3
 Lock pixels :  Array index to top ships( 0 ) :  While Array index valid( ships( 0 )) :  Set vector3 4, ships().px, ships().py, ships().pz :  Project vector3 4, 4, 1, 2, 3 :  If Z vector3( 4 ) > 0 And Z vector3( 4 ) < 1.0 :  If Point( X vector3( 4 ), Y vector3( 4 )) = 0x252525
 For x = 0 To ships().size :  For y = 0 To ships().size :  Dot X vector3( 4 ) + x, Y vector3( 4 ) + y, ships().from :  Next :  Next :  Endif :  Endif :  Inc ships().px, ships().dx :  Inc ships().py, ships().dy :  Inc ships().pz, ships().dz :  If Abs( ships().px - ships().tx ) < 10 :  If Abs( ships().py - ships().ty ) < 10 :  If Abs( ships().pz - ships().tz ) < 10 :  If Planets( ships().aim ).owner = ships().from :  Inc Planets( ships().aim ).fleet, ships().troops :  Else :  Dec Planets( ships().aim ).fleet, ships().troops
 If Planets( ships().aim ).fleet <= 0  :  Planets( ships().aim ).owner = ships().from :  Color object ships().aim, ships().from :  Planets( ships().aim ).fleet = -Planets( ships().aim ).fleet :  Endif :  Endif :  Array delete element ships() :  Endif
 Endif :  Endif :  Next array index ships( 0 ) : Endwhile :  Unlock pixels :  For i = 1 To maxplanets :  dist# = Sqrt( ( camera position x() - Object position x( i ))^2 + ( camera position y() - Object position y( i ))^2 + ( camera position z() - Object position z( i ))^2 ) :  osx = Object screen x( i ) :  osy = Object screen y( i ) :  os = Object size( i )/dist#*1000
 Line osx -os/2, osy + os/2, osx - os, osy + os :  Line osx - os, osy + os, osx - os - 10, osy + os :  Text osx - os - 10, osy + os - 10, str$( Planets( i ).fleet) :  Next :  If Mouseclick() = 1 :  If selb = 0 And po = 0 :  sfx = mx :  sfy = my :  selb = 1 :  Endif :  If selb = 1 :  stx = mx :  sty = my :  Line sfx, sfy, stx, sfy  :  Line sfx, sfy, sfx, sty
 Line sfx, sty, stx, sty  :  Line stx, sfy, stx, sty :  Empty array selplanets(0) :  If sfx > stx :  ntx = sfx  :  nfx = stx :  Else :  ntx = stx  :  nfx = sfx :  Endif :  If sfy > sty :  nty = sfy  :  nfy = sty :  Else :  nty = sty  :  nfy = sfy :  Endif :  For i = 1 To maxplanets :  If Planets( i ).owner = player( 1 ) And Object screen x( i ) > nfx And Object screen y( i ) > nfy And Object screen x( i ) < ntx And Object screen y( i ) < nty :  Array index to stack selplanets(0) :  Add to stack selplanets(0) :  selplanets() = i :  Endif :  Next :  Endif
 If selb = 0 And Array count( selplanets( 0 )) > -1 :  For i = 0 To Array count( selplanets( 0 )) :  Array index to queue ships( 0 ) :  SendShips( selplanets( i ), po, Planets( selplanets( i )).fleet/2 ) :  Planets( selplanets( i ) ).fleet = Planets( selplanets( i ) ).fleet/2 :  Next :  Empty array selplanets(0) :  Endif :  Else :  selb = 0 :  Endif :  If Array count( selplanets( 0 )) > -1 :  For i = 0 To Array count( selplanets( 0 )) :  dist# = Sqrt( ( camera position x() - Object position x( selplanets(i) ))^2 + ( camera position y() - Object position y( selplanets(i) ))^2 + ( camera position z() - Object position z( selplanets(i) ))^2 )
 Circle Object screen x( selplanets(i) ), Object screen y( selplanets(i) ), 1.0/dist#*1000*Object size( selplanets(i) ) :  If po :  Set vector3 4, Object screen x( po ) - Object screen x( selplanets( i ) ), Object screen y( po ) - Object screen y( selplanets( i ) ), 0 :  Normalize vector3 4, 4 :  Scale vector3 4, 4, 1.0/dist#*1000*Object size( selplanets(i) ) :  fx = Object screen x( selplanets( i )) + X vector3( 4 ) :  fy = Object screen y( selplanets( i )) + Y vector3( 4 )
 dist# = Sqrt( ( camera position x( ) - Object position x( po ))^2 + ( camera position y( ) - Object position y( po ))^2 + ( camera position z( ) - Object position z( po ))^2 ) :  Normalize vector3 4, 4 :  Scale vector3 4, 4, 1.0/dist#*1000*Object size( po ) :  tx = Object screen x( po ) - X vector3( 4 )
 ty = Object screen y( po ) - Y vector3( 4 ) :  Line fx, fy, tx, ty :  Ink 0xff0000, 0xff0000 :  Circle Object screen x( po ), Object screen y( po ), 1.0/dist#*1000*Object size( po ) :  Ink 0xffffff, 0xffffff :  Endif :  Next :  Endif :  If Timer() - controletime > 500 :  controletime = timer() :  i = 0 :  Repeat :  Inc i :  Until Planets( i ).owner > 0 :  o = Planets( i ).owner :  Repeat :  Inc i :  Until o <> Planets( i ).owner Or i = maxplanets :  If i = maxplanets And winner = 0 :  For j = 1 To 6 :  If player( j ) = Planets( i ).owner : winner = j : Endif :  Next :  winnertime = timer() - gametime
 Endif :  Endif :  Paste image 1, 0, 0 :  Text 1, 5, "FPS: " + str$( Screen fps( )) :  Text 100, 5, "Time: " + str$( Int(( Timer() - gametime )*.001 )) + " s" :  Text 200, 5, "Ships: " + str$( Array count( ships( 0 )) + 1 ) :  Text 800, 5, "[N]ew game            [Q]uit" : Text Screen width() - 120, Screen height() - 20, "Copyright by Azrael 2007" : If Inkey$() = "n" :  CreatePlanets( maxplanets, players ) :  Empty array ships(0) :  Empty array selplanets(0) :  d = 800  :  troops = 0  :  KItime = Timer()  :  gametime = timer() :  winner = 0 :  Sleep 500 :  Endif :  If Inkey$() = "q" :  End :  Endif :  If winner :  Lock pixels :  Box Screen width()/2 - 101, Screen height()/2 - 51, Screen width()/2 + 101, Screen height()/2 + 51 :  Ink 0x252525, 0x252525
 Box Screen width()/2 - 100, Screen height()/2 - 50, Screen width()/2 + 100, Screen height()/2 + 50 :  Unlock pixels :  Ink player( winner ), player( winner ) :  Center text Screen width()/2, Screen height()/2 - 30, "The Winner is player " + str$( winner ) :  Ink 0xffffff, 0xffffff :  Center text Screen width()/2, Screen height()/2, "He needed " + str$( winnertime*0.001 ) + " s" :  Center text Screen width()/2, Screen height()/2 + 30, "Press 'N' for new round or 'Q' to quit"
 If Escapekey() : End : Endif :  Endif :  Position camera 0, 0, 0  :  Inc d, mmz  :  Move camera - d :  If Mouseclick() = 2  :  Position camera 0, 0, 0  :  Turn camera left mmx  :  Pitch camera up mmy  :  Move camera - d  :  Endif :  Position light 1, Camera position x(), Camera position y(), Camera position z() :  Sync : Loop
Function  CreatePlanets(maxplanets, players)
    For i = 1 To 100
        If Object exist( i ) Then Delete object i
    Next blah
    For i = 1 To maxplanets
        If players > 0
            Planets( i ).Size =  100
            Planets( i ).fleet = 100
            Planets( i ).owner = player( i )
        Else
            Planets( i ).Size =  Rnd( 80 ) + 20
            Planets( i ).fleet = Rnd( 100 ) + 1
            Planets( i ).owner = 0
        Endif
        Make object sphere i, Planets( i ).Size, 20, 20
        If players > 0
            Color object i, player( i )
            Dec players
        Endif
        Repeat : Position object i, Rnd( 1000 ) - 500, Rnd( 1000 ) - 500, Rnd( 1000 ) - 500 : Until Object collision( i, 0) =  0
    Next
Endfunction
Function SendShips( source As Integer, destination As Integer, amount As Integer )
If amount > 50 :  Repeat :  Add to queue ships( 0 ) :  ships().px = Object position x( source ) + Rnd(200) - 100 :  ships().py = Object position y( source ) + Rnd(200) - 100 :  ships().pz = Object position z( source ) + Rnd(200) - 100 :  ships().tx = Object position x( destination ) :  ships().ty = Object position y( destination ) :  ships().tz = Object position z( destination ) :  Set vector3 4, ships().tx - ships().px, ships().ty - ships().py, ships().tz - ships().pz :  Normalize vector3 4, 4 :  ships().dx = X vector3( 4 ) :  ships().dy = Y vector3( 4 ) :  ships().dz = Z vector3( 4 ) :  ships().aim = destination :  ships().from = Planets( source ).owner :  ships().size = 3 :  ships().troops = 10 :  Dec amount, 10 :  Until amount <= 10 :  Endif
Repeat :  Add to queue ships( 0 ) : ships().px = Object position x( source ) + Rnd(200) - 100 :  ships().py = Object position y( source ) + Rnd(200) - 100 :  ships().pz = Object position z( source ) + Rnd(200) - 100 :  ships().tx = Object position x( destination ) :  ships().ty = Object position y( destination ) :  ships().tz = Object position z( destination ) :  Set vector3 4, ships().tx - ships().px, ships().ty - ships().py, ships().tz - ships().pz :  Normalize vector3 4, 4 :  ships().dx = X vector3( 4 ) :  ships().dy = Y vector3( 4 ) :  ships().dz = Z vector3( 4 ) :  ships().aim = destination :  ships().from = Planets( source ).owner :  ships().size = 1 :  ships().troops = 1 :  Dec amount, 1 :  Until amount =< 0
Endfunction
Data 0xff0000, 0x00ff00, 0x0000ff, 0xffff00, 0xff00ff, 0x00ffff



original:

+ Code Snippet
Sync on : Sync rate 0 : Sync : Set display mode 1024, 768, 32
Disable escapekey
Color backdrop 0x252525
Set text font "Tahoma"

Type tship
    px      As Float
    py      As Float
    pz      As Float
    tx      As Float
    ty      As Float
    tz      As Float
    dx      As Float
    dy      As Float
    dz      As Float
    aim     As Integer
    from    As Integer
    size    As Integer
    troops  As Integer
Endtype


Type tplanet
    size    As Integer
    fleet   As Integer
    owner   As integer
Endtype




rem Abfragen für Spiel

Cls

Input "How many opponents? (1 - 5) default 5 :", players
Input "How many planets? (min. " + str$( players + 2 ) + ") default 20 : ", maxplanets
Input "Difficulty? (easy: 30  hard: 300) default 100 : ", difficulty

If players = 0 Then players = 5
If difficulty = 0 Then difficulty = 100
If maxplanets = 0 Then maxplanets = 20

Inc players
If players > 6 Then players = 6
If players <= 1 Then players = 2

If maxplanets <= players Then maxplanets = players + 1
If maxplanets > 100 Then maxplanets = 100

If difficulty < 30 Then difficulty = 30
If difficulty > 300 Then difficulty = 300




rem Daten & Variablen


Dim Planets( 100 )   As tplanet
Dim selplanets( -1 )        As Integer
Dim ships( -1 )             As tship
Dim player( 6 )             As Dword

null = Make matrix4( 1 )
null = Make matrix4( 2 )
null = Make matrix4( 3 )

null = Make vector3( 4 )



For i = 1 To 6
    Read player( i )
Next





Rem Sonstiges

Make light 1
Set light range 1, 100000


Ink 0x252525, 0x252525
Box 0, 0, Screen width(), 30
Ink 0xffffff, 0xffffff
Set text size 20
Center text 500, 1, "ships v1.0"
Line 0, 29, Screen width(), 29
Get image 1, 0, 0, Screen width(), 30, 3
Set text size 12



rem create planets

CreatePlanets( maxplanets, players )


d = 800 : troops = 0 : KItime = Timer() : gametime = timer()
game = 0




rem MainLoop



Do
    
    
    Set cursor 0, 35
    
    
    mmx = Mousemovex()
    mmy = Mousemovey()
    mmz = Mousemovez()
    
    
    mx = Mousex()
    my = Mousey()
    
    
    po = Pick object( mx, my, 1, maxplanets )
    
    
    
    
    
    rem Planetenhandling
    
    
    If Timer() - lt > 1000
        
        For i = 1 To maxplanets
            
            If Planets( i ).owner > 0
                
                Inc Planets( i ).fleet, Planets( i ).size*.1
                
            Endif
        Next
        
        lt = timer()
        
    Endif
    
    
    
    
    rem KI
    
    If timer() - KItime > 330 - difficulty
            
        For i = 1 To maxplanets
            
            If Planets( i ).owner > 0 And Planets( i ).owner <> player( 1 )
                
                c = Planets( i ).owner
                
                For j = 1 To maxplanets
                    
                    If Rnd( 300 ) = 1 And i <> j
                        
                        If Planets( j ).owner = c
                            If Planets(j).fleet > Planets(i).fleet
                                SendShips( i, j, Planets( i ).fleet/2 )
                                Planets( i ).fleet = Planets( i ).fleet/2
                            Endif
                        Else
                            If Rnd( 10 ) = 1
                                SendShips( i, j, Planets( i ).fleet/2 )
                                Planets( i ).fleet = Planets( i ).fleet/2
                            Endif
                        Endif
                    Endif
                    
                    
                    
                    If Planets( j ).owner = 0 And Rnd( 20 ) > 2
                        
                        If Rnd( 10 ) > 1
                            If Planets( i ).fleet > 40 And Planets( j ).fleet > 0
                                
                                If Planets( i ).fleet/Planets( j ).fleet > 1.5 And Rnd( 5000 ) > Planets( j ).size
                                    
                                    SendShips( i, j, Planets( i ).fleet/2 )
                                    Planets( i ).fleet = Planets( i ).fleet/2
                                    
                                Endif
                            Endif
                        Endif
                        
                    Else
                        
                        If c <> Planets( j ).owner
                            If Planets( i ).fleet > 40 And Planets( j ).fleet > 0
                                
                                If Planets( i ).fleet/Planets( j ).fleet > 1.5 And Rnd( 5000 ) > Planets( j ).size
                                    
                                    SendShips( i, j, Planets( i ).fleet/2 )
                                    Planets( i ).fleet = Planets( i ).fleet/2
                                    
                                Endif
                            Endif
                        Endif
                        
                    Endif
                Next
            Endif
        Next
        
        KItime = timer()
        
    Endif
    
    
    
    
    
    
    rem Zeichne Schiffe
    
    
    Projection matrix4  1
    View matrix4        2
    World matrix4       3
    
    Lock pixels
    
    Array index to top ships( 0 )
    
    While Array index valid( ships( 0 ))
        
        Set vector3     4, ships().px, ships().py, ships().pz
        Project vector3 4, 4, 1, 2, 3
        
        If Z vector3( 4 ) > 0 And Z vector3( 4 ) < 1.0
            If Point( X vector3( 4 ), Y vector3( 4 )) = 0x252525
                For x = 0 To ships().size
                    For y = 0 To ships().size
                        Dot X vector3( 4 ) + x, Y vector3( 4 ) + y, ships().from
                    Next
                Next
            Endif
        Endif
        
        
        Inc ships().px, ships().dx
        Inc ships().py, ships().dy
        Inc ships().pz, ships().dz
        
        
        If Abs( ships().px - ships().tx ) < 10
            If Abs( ships().py - ships().ty ) < 10
                If Abs( ships().pz - ships().tz ) < 10
                    If Planets( ships().aim ).owner =  ships().from
                        Inc Planets( ships().aim ).fleet, ships().troops
                    Else
                        Dec Planets( ships().aim ).fleet, ships().troops
                        If  Planets( ships().aim ).fleet <= 0 
                            Planets( ships().aim ).owner =  ships().from
                            Color object ships().aim, ships().from
                            Planets( ships().aim ).fleet = -Planets( ships().aim ).fleet
                        Endif
                    Endif
                    Array delete element ships()
                Endif
            Endif
        Endif
        
    Next array index ships( 0 )
    
    
    Endwhile
    
    Unlock pixels
    
    
    
    
    
    rem GUI
    
    
    For i = 1 To maxplanets
        
        dist#   = Sqrt( ( camera position x() - Object position x( i ))^2 + ( camera position y() - Object position y( i ))^2 + ( camera position z() - Object position z( i ))^2 )
        osx     = Object screen x( i )
        osy     = Object screen y( i )
        os      = Object size( i )/dist#*1000
        
        
        
        Line osx -os/2, osy + os/2, osx - os, osy + os
        Line osx - os, osy + os, osx - os - 10, osy + os
        Text osx - os - 10, osy + os - 10, str$( Planets( i ).fleet)
        
        
    Next
    
    
    
    If Mouseclick() = 1
        
        
        If selb = 0 And po = 0
            
            sfx = mx
            sfy = my
            selb = 1
            
        Endif
        
        
        
        If selb = 1
            
            stx = mx
            sty = my
            
            Line sfx, sfy, stx, sfy :  Line sfx, sfy, sfx, sty : Line sfx, sty, stx, sty : Line stx, sfy, stx, sty
            
            Empty array selplanets(0)
            
            If sfx > stx
                ntx = sfx : nfx = stx
            Else
                ntx = stx : nfx = sfx
            Endif
            
            If sfy > sty
                nty = sfy : nfy = sty
            Else
                nty = sty : nfy = sfy
            Endif
            
            
            
            For i = 1 To maxplanets
                
                If Planets( i ).owner = player( 1 ) And Object screen x( i ) > nfx And Object screen y( i ) > nfy And Object screen x( i ) < ntx And Object screen y( i ) < nty
                    
                    Array index to stack selplanets(0)
                    Add to stack selplanets(0)
                    selplanets() = i
                    
                Endif
                
            Next
            
        Endif
        
        
        
        If selb = 0 And Array count( selplanets( 0 )) > -1
            
            
            For i = 0 To Array count( selplanets( 0 ))
                Array index to queue ships( 0 )
                SendShips( selplanets( i ), po, Planets( selplanets( i )).fleet/2 )
                Planets( selplanets( i ) ).fleet = Planets( selplanets( i ) ).fleet/2
            Next
            
            
            Empty array selplanets(0)
            
            
        Endif
        
    Else
        selb = 0
    Endif
    
    
    
    If Array count( selplanets( 0 )) > -1
        
        For i = 0 To Array count( selplanets( 0 ))
            
            dist# = Sqrt( ( camera position x() - Object position x( selplanets(i) ))^2 + ( camera position y() - Object position y( selplanets(i) ))^2 + ( camera position z() - Object position z( selplanets(i) ))^2 )
            
            Circle Object screen x( selplanets(i) ), Object screen y( selplanets(i) ), 1.0/dist#*1000*Object size( selplanets(i) )
            
            If po
                
                Set vector3         4, Object screen x( po ) - Object screen x( selplanets( i ) ), Object screen y( po ) - Object screen y( selplanets( i ) ), 0
                Normalize vector3   4, 4
                Scale vector3       4, 4,  1.0/dist#*1000*Object size( selplanets(i) )
                
                fx = Object screen x( selplanets( i )) + X vector3( 4 )
                fy = Object screen y( selplanets( i )) + Y vector3( 4 )
                
                
                dist# = Sqrt( ( camera position x( ) - Object position x( po ))^2 + ( camera position y( ) - Object position y( po ))^2 + ( camera position z( ) - Object position z( po ))^2 )
                Normalize vector3   4, 4
                Scale vector3       4, 4,  1.0/dist#*1000*Object size( po )
                
                
                tx = Object screen x( po )  - X vector3( 4 )
                ty = Object screen y( po )  - Y vector3( 4 )
                
                Line fx, fy, tx, ty
                
                Ink 0xff0000, 0xff0000
                Circle Object screen x( po ), Object screen y( po ), 1.0/dist#*1000*Object size( po )
                Ink 0xffffff, 0xffffff
                
            Endif
            
        Next
        
    Endif
    
    
    
    rem Siegkontrolle
    
    If Timer() - controletime > 500
        
        controletime = timer()
        
        i = 0
        
        Repeat
            
            Inc i
            
        Until Planets( i ).owner > 0
        
        o = Planets( i ).owner
        
        
        Repeat
            
            Inc i
            
        Until o <> Planets( i ).owner Or i = maxplanets
        
        If i = maxplanets And winner = 0
            For j = 1 To 6
                If player( j ) = Planets( i ).owner Then winner = j
            Next
            
            winnertime = timer() - gametime
            
        Endif
        
    Endif
    
    
    Paste image 1, 0, 0
    Text   1, 5, "FPS: " + str$( Screen fps( ))
    Text 100, 5, "Time: " + str$( Int(( Timer() - gametime )*.001 )) + " s"
    Text 200, 5, "Ships: " + str$( Array count( ships( 0 )) + 1 )
    Text 800, 5, "[N]ew game            [Q]uit"
    
    Text Screen width() - 120, Screen height() - 20, "Copyright by Azrael 2007"
    
    If Inkey$() = "n"
        
        CreatePlanets( maxplanets, players )
        Empty array ships(0)
        Empty array selplanets(0)
        d = 800 : troops = 0 : KItime = Timer() : gametime = timer()
        winner = 0
        Sleep 500
        
    Endif
    
    If Inkey$() = "q"
        
        End
        
    Endif
    
    
    If winner
        Lock pixels
        Box Screen width()/2 - 101, Screen height()/2 - 51, Screen width()/2 + 101, Screen height()/2 + 51
        Ink 0x252525, 0x252525
        Box Screen width()/2 - 100, Screen height()/2 - 50, Screen width()/2 + 100, Screen height()/2 + 50
        Unlock pixels
        Ink player( winner ), player( winner )
        Center text Screen width()/2, Screen height()/2 - 30, "The Winner is player " + str$( winner )
        Ink 0xffffff, 0xffffff
        Center text Screen width()/2, Screen height()/2, "He needed " + str$( winnertime*0.001 ) + " s"
        Center text Screen width()/2, Screen height()/2 + 30, "Press 'N' for new round or 'Q' to quit"
        
        If Escapekey() Then End
        
    Endif
    
    
    rem Kamerakontrolle
    
    Position camera 0, 0, 0 : Inc d, mmz : Move camera - d
    If Mouseclick() = 2 : Position camera 0, 0, 0 : Turn camera left mmx : Pitch camera up  mmy : Move camera - d : Endif
    Position light 1, Camera position x(), Camera position y(), Camera position z()
    
    
    
    
    
    
    Sync
    
Loop




Function  CreatePlanets(maxplanets, players)
    
    For i = 1 To 100
        If Object exist( i ) Then Delete object i
    Next blah
    
    For i = 1 To maxplanets
        If players > 0
            Planets( i ).Size =  100
            Planets( i ).fleet = 100
            Planets( i ).owner = player( i )
        Else
            Planets( i ).Size =  Rnd( 80 ) + 20
            Planets( i ).fleet = Rnd( 100 ) + 1
            Planets( i ).owner = 0
        Endif
        
        Make object sphere i, Planets( i ).Size, 20, 20
        
        If players > 0
            Color object i, player( i )
            Dec players
        Endif
        Repeat : Position object i, Rnd( 1000 ) - 500, Rnd( 1000 ) - 500, Rnd( 1000 ) - 500 : Until Object collision( i, 0) =  0
    Next
    
Endfunction



Function SendShips( source As Integer, destination As Integer, amount As Integer )
    
    If amount > 50
        Repeat
            
            Add to queue ships( 0 )
            ships().px = Object position x( source ) + Rnd(200) - 100
            ships().py = Object position y( source ) + Rnd(200) - 100
            ships().pz = Object position z( source ) + Rnd(200) - 100
            ships().tx = Object position x( destination )
            ships().ty = Object position y( destination )
            ships().tz = Object position z( destination )
            Set vector3       4, ships().tx - ships().px, ships().ty - ships().py, ships().tz - ships().pz
            Normalize vector3 4, 4
            ships().dx      = X vector3( 4 )
            ships().dy      = Y vector3( 4 )
            ships().dz      = Z vector3( 4 )
            ships().aim     = destination
            ships().from    = Planets( source ).owner
            ships().size    = 3
            ships().troops  = 10
            
            Dec amount, 10
            
        Until amount <= 10
        
    Endif
    
    Repeat
        Add to queue ships( 0 )
        ships().px = Object position x( source ) + Rnd(200) - 100
        ships().py = Object position y( source ) + Rnd(200) - 100
        ships().pz = Object position z( source ) + Rnd(200) - 100
        ships().tx = Object position x( destination )
        ships().ty = Object position y( destination )
        ships().tz = Object position z( destination )
        Set vector3       4, ships().tx - ships().px, ships().ty - ships().py, ships().tz - ships().pz
        Normalize vector3 4, 4
        ships().dx      = X vector3( 4 )
        ships().dy      = Y vector3( 4 )
        ships().dz      = Z vector3( 4 )
        ships().aim     = destination
        ships().from    = Planets( source ).owner
        ships().size    = 1
        ships().troops  = 1
        
        Dec amount, 1
    Until amount =< 0
    
Endfunction




Data 0xff0000, 0x00ff00, 0x0000ff, 0xffff00, 0xff00ff, 0x00ffff




Here is a picture:





Have fun playing it

sry for my english

Back to top
xbasix Find user on ICQ
Report this message as abusive
Spopovich

User


Joined: Wed Jul 12th 2006
Location: Cyberspace
Posted: 26th Mar 2007 16:48           | link | toggle

Wow that was pretty cool and addicting. Nice job.

Do not ask what the forums can do ask what you can do for the forums.
Back to top
Report this message as abusive
jasonhtml

User


Joined: Sat Mar 20th 2004
Location: OC, California, USA
Posted: 26th Mar 2007 21:51     Edited: 26th Mar 2007 21:51     | link | toggle

i love this game! its just spheres and plains, but i love it! the AI is decent i thought i probably played this for a good 20 minutes

100 planets with 5 opponents on highest difficulty was awsome

Back to top
MMOGWave Send AIM user a message
Report this message as abusive
Azrael

User


Joined: Wed Mar 2nd 2005
Location: Germany
Posted: 27th Mar 2007 10:33           | link | toggle

Hey THX people

Any suggestions to improve the game? Which makes it worth to play it twice?

Back to top
xbasix Find user on ICQ
Report this message as abusive
D Man

User


Joined: Thu Oct 3rd 2002
Location: Germany
Posted: 27th Mar 2007 12:54           | link | toggle

My favourite so far. Great job!

Quote: "its just spheres and plains"
No plains, as far as I can see .

Quote: "Any suggestions to improve the game?"

You could improve visuals by adding some sort of randomness in the path when sending fleets (so they would look much more realistic starting from different positions on the surface of the planets; you may also consider using hermite or cubic splines for the path for coherent randomness).

I did play this much longer than 20 minutes by the way (unfortunately ).

God is real, unless declared integer.
Back to top
Find user on ICQ
Report this message as abusive
Master Xilo

User


Joined: Fri Sep 8th 2006
Location: Bern, Switzerland
Posted: 31st Mar 2007 18:06           | link | toggle

wow that's a great, medialess game in 50 lines!!!
+good idea
+well done AI
+...
Back to top
Hurricane-Eye Entertainment
Report this message as abusive
honor blade

User


Joined: Sun Oct 29th 2006
Location: Cyberspace
Posted: 1st Apr 2007 11:01           | link | toggle

I can't play it with DBP demo download. It says "cannot understand item 0xff0000 in DATA statement at line 50".
Back to top
Report this message as abusive
Google Ad
Back to top
 
Azrael

User


Joined: Wed Mar 2nd 2005
Location: Germany
Posted: 1st Apr 2007 13:52     Edited: 2nd May 2007 16:55     | link | toggle

Quote: "I can't play it with DBP demo download. It says "cannot understand item 0xff0000 in DATA statement at line 50"."

I've uploaded the executeable. Have fun playing it.

Quote: "
Quote: ""its just spheres and plains""
No plains, as far as I can see "

Thats right. I've used a Dot3D Funktion using the dbp math commands.
Using plains would certainly slow the game down.

Back to top
xbasix Find user on ICQ
Download: ships v1.0.zip Size: 1975251 bytesReport this message as abusive
Zombie 20

User


Joined: Sun Nov 26th 2006
Location: Etters, PA
Posted: 14th Apr 2007 23:01           | link | toggle

makes me want to learn this that much faster, nice job.

Back to top
Send AIM user a message
Report this message as abusive
Azrael

User


Joined: Wed Mar 2nd 2005
Location: Germany
Posted: 3rd May 2007 04:49           | link | toggle

Hey!

Winner

That's great

Back to top
xbasix Find user on ICQ
Report this message as abusive
Zombie 20

User


Joined: Sun Nov 26th 2006
Location: Etters, PA
Posted: 6th May 2007 02:34           | link | toggle

good job mate

Back to top
Send AIM user a message
Report this message as abusive
Alquerian

User


Joined: Wed Mar 29th 2006
Location: Northern California
Posted: 10th May 2007 14:17           | link | toggle

Yeah good job, easily the most addictive game I have played on DBP.

Visit the Wip!
Back to top
Fantasy Multimedia
Report this message as abusive
qwe

User


Joined: Wed Sep 3rd 2003
Location: place
Posted: 6th Aug 2007 01:52           | link | toggle

great game

perhaps make a turn-based game and a menu so that you can play against other people like a boardgame?
Back to top
Send AIM user a message
Report this message as abusive
Keo C

User


Joined: Fri Aug 3rd 2007
Location: Somewhere between here and there.
Posted: 6th Aug 2007 22:02           | link | toggle

How is this a 20-liner? I'm just kidding. It looks great!

Uhhhhhh.....I forgot
Back to top
KCS Game Studio
Report this message as abusive

Go to the first page of this board Return to the Forum Menu Post Message
14 Messages - Page   of 1   
Search the Forum

Sorry, but it has been so long since anyone replied to this Thread that it has been automatically locked.
You may read it but not reply.

Forum Search

Enter a word or phrase to search our Forum for:

Thread Subject Search
Search Phrase:
Search Scope: Entire forum
Just this board
 
Google Forum Search
Search Phrase:
 
Apollo v2.02


Game Creator Store
Privacy Policy AUP Top of Page