Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Space Race
#8
(12-14-2023, 06:45 AM)johnno56 Wrote: ...
If you have any difficulties or questions just ask... If I do not know the answer I am sure that someone else on this site will know... lol
...

Hi Johnno56,

Your source code of Space Race in Naalaa is very useful for me as a reference to study the logic of the game. 
Just for fun, I made some modifications  Cool

1. The program structure is grouped into 3 categories :    
    - INITIALIZATION   : set up windows, variables    
    - MAIN PROGRAM   : do ... loop
    - FUNCTIONS     
          InitObjects()
          GameIntro()
          MoveRocks()
          DisplayPlayers()
          PlayersMovement()
          CalculateScore()

2. Using Dot notation
Code:
function InitObjects()

  'computer player
  player.x = 60;   
  player.y = 300; 
  player.w = 15; 
  player.h = 16
   
  'human player
  player2.x = 165;
  player2.y = 300;
  player2.w = 15;
  player2.h = 16
  ...
endfunc

3. It is a simplified version
     i.e.Rocks only move from left to right  Big Grin
     i.e.Human Player vs Computer Player (only move forward, most of the time it hits the rocks  Big Grin )
Code:
function PlayersMovement()

    'Computer Player (Auto movement)   
    player.y = player.y - (0.1*rnd(10))
    if player.y <= -15
        score1 = score1 + 1; player.y = 300
    endif

    'Human Player
    if keydown(KEY_UP)
        player2.y = player2.y - 1
        if player2.y <= -15
            score2 = score2 + 1; player2.y = 300
        endif
    endif
    if keydown(KEY_DOWN)
        player2.y = player2.y + 1
        if player2.y > 300
            player2.y = 300
        endif
    endif
endfunc

Once again, thanks to Johnno56 for having shared the source code of Space Race in Naalaa  Big Grin


Attached Files
.n7   spacerace_simplified.n7 (Size: 6.2 KB / Downloads: 2)
Reply


Messages In This Thread
Space Race - by johnno56 - 12-13-2023, 07:20 PM
RE: Space Race - by 1micha.elok - 12-14-2023, 04:23 AM
RE: Space Race - by johnno56 - 12-14-2023, 06:45 AM
RE: Space Race - by Marcus - 12-19-2023, 06:23 AM
RE: Space Race - by 1micha.elok - 12-20-2023, 03:50 AM
RE: Space Race - by kevin - 12-15-2023, 03:14 PM
RE: Space Race - by johnno56 - 12-15-2023, 06:37 PM
RE: Space Race - by johnno56 - 12-19-2023, 10:01 AM
RE: Space Race - by johnno56 - 12-20-2023, 07:38 AM
RE: Space Race - by 1micha.elok - 12-22-2023, 08:54 AM
RE: Space Race - by johnno56 - 12-22-2023, 10:53 AM
RE: Space Race - by Marcus - 12-23-2023, 09:40 PM
RE: Space Race - by johnno56 - 12-24-2023, 07:07 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)