Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Asteroids
#1
I remember spending hours playing this game back in 1979/80, and it's been fun trying to recreate some of it in NaaLaa 7. I've deliberately left the graphics and font minimal, simply because that is how I remember it......

   

Instructions are in the game - as usual, please let me know of any bugs that you run into.....


.zip   Asteroids - final.zip (Size: 914.62 KB / Downloads: 5)
Reply
#2
Who does not enjoy a game of Asteroids? Very cool...

One small suggestion. The appearance of the 'enemy' is a little predictable... Not the actual act of appearing... 'where' it appears. After destroying many rocks, all I had to do was, aim at the top left corner and the enemy was destroyed before it knew it was there.. Perhaps randomly select which side of the screen it should appear.? Other that that the game is brilliant... Oh, I forgot to also mention... Lives... I could do with 'infinite' lives... if not, shields... My poor little ship cannot take much more of this 'fragmentation'... *sigh*

Great job!

J

ps: If you are reproducing the 'classics'... may I suggest Donkey Kong or Battlezone? lol
May your journey be free of incident.
Live long and prosper.
Reply
#3
Oh. Ignore my last posting. It looks like I was terribly unlucky, that all the games that I played, the enemy started in the top left of the screen... That theory has now been disproved... the mongrel crept up behind me, from the lower right... I am beginning to hate fragmentation... *sigh* Nicely done... assassin!
May your journey be free of incident.
Live long and prosper.
Reply
#4
(07-29-2022, 07:56 PM)johnno1956 Wrote: Who does not enjoy a game of Asteroids? Very cool...

One small suggestion. The appearance of the 'enemy' is a little predictable... Not the actual act of appearing... 'where' it appears. After destroying many rocks, all I had to do was, aim at the top left corner and the enemy was destroyed before it knew it was there.. Perhaps randomly select which side of the screen it should appear.? Other that that the game is brilliant... Oh, I forgot to also mention... Lives... I could do with 'infinite' lives... if not, shields... My poor little ship cannot take much more of this 'fragmentation'... *sigh*

Great job!

J

ps: If you are reproducing the 'classics'... may I suggest Donkey Kong or Battlezone? lol

Thanks Johnno....if you want infinite lives for practice, add this line somewhere in the game loop - I used line 174:
Code:
if lives < 3 then lives = 3

.....be warned though, it does get a little crowded, and fast, as the game progresses.......

One tip to avoid the enemy missiles - keep your spaceship moving away from the line of the bullets by 90 degrees or so.
Reply
#5
Only kidding about the lives... but the shields... there just has to be shields... Oh, random teleport, in case the shields do not work... power-ups (stronger and faster bullets)... pause button (for when there is a call of nature or one runs out of snacks)... Stronger asteroids (more hits to destroy)... Time limited bonus scoring (10 times normal score)... Self destruct weapon. (everything is destroyed) Moo Ha Ha....
May your journey be free of incident.
Live long and prosper.
Reply
#6
That was fun Smile

I made it to level 4 and scored 2480 points, but I've never been good at Asteroids. No bugs found! I haven't looked at the code yet.
Reply
#7
Now I've looked at the code Smile

I only have one small and possibly unnecessary suggestion, a change in the function polygons_update_world_values:

Code:
function polygons_update_world_values(polygons)

foreach polygon in polygons
mid_x_calc = 0
mid_y_calc = 0

    if not sizeof(polygon.new_wireframe) polygon.new_wireframe = copy(polygon.original_wireframe)
    if not sizeof(polygon.world_wireframe) polygon.world_wireframe = copy(polygon.original_wireframe)

    for j = 0 to sizeof(polygon.original_wireframe) - 1
        'create initial new_wireframe - this will be subsequently
        'updated each time the polygons_rotate function is called.
        'polygons_rotate is the only function that needs new_wireframe.
        'polygon.new_wireframe[j] = [polygon.original_wireframe[j][0] ,
        '                                polygon.original_wireframe[j][1] ]
        polygon.new_wireframe[j][0] = polygon.original_wireframe[j][0]
        polygon.new_wireframe[j][1] = polygon.original_wireframe[j][1]
       
        'polygon.world_wireframe[j] = [polygon.original_wireframe[j][0] + polygon.x,
        '                                polygon.original_wireframe[j][1] + polygon.y]
        polygon.world_wireframe[j][0] = polygon.original_wireframe[j][0] + polygon.x
        polygon.world_wireframe[j][1] = polygon.original_wireframe[j][1] + polygon.y
                                                                                 
        mid_x_calc = mid_x_calc + polygon.world_wireframe[j][0] ' this will be used for collision detection
       
        mid_y_calc = mid_y_calc + polygon.world_wireframe[j][1] ' this will be used for collision detection
    next
    polygon.mid_x = mid_x_calc / sizeof(polygon.original_wireframe)'not the most accurate measure, but good enough!
    polygon.mid_y = mid_y_calc / sizeof(polygon.original_wireframe)
next
endfunc

Rather than creating new arrays every tick for every polygon, do it once (where I use 'copy') and re-use. There's absolutely nothing wrong with doing it the way you do it. I'm GLAD you're doing it that way, because it lets me see how well the garbage collector works and how collecting garbage affects performance.
Reply
#8
(07-30-2022, 09:56 AM)Marcus Wrote: Now I've looked at the code Smile

I only have one small and possibly unnecessary suggestion, a change in the function polygons_update_world_values:

Code:
function polygons_update_world_values(polygons)

foreach polygon in polygons
mid_x_calc = 0
mid_y_calc = 0

    if not sizeof(polygon.new_wireframe) polygon.new_wireframe = copy(polygon.original_wireframe)
    if not sizeof(polygon.world_wireframe) polygon.world_wireframe = copy(polygon.original_wireframe)

    for j = 0 to sizeof(polygon.original_wireframe) - 1
        'create initial new_wireframe - this will be subsequently
        'updated each time the polygons_rotate function is called.
        'polygons_rotate is the only function that needs new_wireframe.
        'polygon.new_wireframe[j] = [polygon.original_wireframe[j][0] ,
        '                                polygon.original_wireframe[j][1] ]
        polygon.new_wireframe[j][0] = polygon.original_wireframe[j][0]
        polygon.new_wireframe[j][1] = polygon.original_wireframe[j][1]
       
        'polygon.world_wireframe[j] = [polygon.original_wireframe[j][0] + polygon.x,
        '                                polygon.original_wireframe[j][1] + polygon.y]
        polygon.world_wireframe[j][0] = polygon.original_wireframe[j][0] + polygon.x
        polygon.world_wireframe[j][1] = polygon.original_wireframe[j][1] + polygon.y
                                                                                 
        mid_x_calc = mid_x_calc + polygon.world_wireframe[j][0] ' this will be used for collision detection
       
        mid_y_calc = mid_y_calc + polygon.world_wireframe[j][1] ' this will be used for collision detection
    next
    polygon.mid_x = mid_x_calc / sizeof(polygon.original_wireframe)'not the most accurate measure, but good enough!
    polygon.mid_y = mid_y_calc / sizeof(polygon.original_wireframe)
next
endfunc

Rather than creating new arrays every tick for every polygon, do it once (where I use 'copy') and re-use. There's absolutely nothing wrong with doing it the way you do it. I'm GLAD you're doing it that way, because it lets me see how well the garbage collector works and how collecting garbage affects performance.
Thanks Marcus - I find it very useful to have suggestions for optimising my code - it can sometimes be difficult for me to calculate what impact these changes make to the efficient running of the program. I tend just to look at the frames per second while the programs run, and as long as it stays above 60 I am content - I guess I should give a little thought to making this check a little more sophisticated......
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)