Author Topic: Glowing Rocks from Outer Space  (Read 9525 times)

Offline Cliff3D

  • Dr. Type
  • ****
  • Posts: 268
    • View Profile
Re: Glowing Rocks from Outer Space
« Reply #15 on: 2010-Sep-17 »
Well, the updated version plays very nicely here :D

All I want now is BattleZone (supporting 2 joysticks on a gamepad for individual tread control) and maybe a glowy-ghostly version of Pacman :D

Offline Cliff3D

  • Dr. Type
  • ****
  • Posts: 268
    • View Profile
Re: Glowing Rocks from Outer Space
« Reply #16 on: 2010-Sep-18 »
Hmmm - I wouldn't want to delay release of the source code one iota, but I wonder - could the small UFO be a touch smaller?

Offline Bursar

  • Mr. Drawsprite
  • **
  • Posts: 63
    • View Profile
Re: Glowing Rocks from Outer Space
« Reply #17 on: 2010-Sep-19 »
I've put the source code up: http://tymargames.co.uk/wp-content/uploads/2010/09/GlowingRocksSource.zip

I'd be interested in any feedback on the code, particuarly as I'm new to GLB.

Offline Cliff3D

  • Dr. Type
  • ****
  • Posts: 268
    • View Profile
Re: Glowing Rocks from Outer Space
« Reply #18 on: 2010-Sep-23 »
I'm afraid I haven't looked at the code (I'm a newbie to GLBasic anyway) but I've voted for the app in the showroom anyway :)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10760
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Glowing Rocks from Outer Space
« Reply #19 on: 2010-Sep-23 »
Some comments on the code - it's mostly nickpicking - nothing serious. Your code shows you're an experienced programmer.

-functions that return nothing or true/false should be integer: FUNCTION foo%:
-why not using the DELETE inside the FOR loop but set a bMustBeDeleted Flag?
-the "player.state$" and such might be better to be an integer and constants instead of strings (especially for small platoforms), but again, that's all no big deal. The code is great!

Offline Bursar

  • Mr. Drawsprite
  • **
  • Posts: 63
    • View Profile
Re: Glowing Rocks from Outer Space
« Reply #20 on: 2010-Sep-23 »
Thanks :)

Quote
functions that return nothing or true/false should be integer: FUNCTION foo%:
Useful to know - that's just my inexperience with the language. Took me long enough to get used to putting the colon on the end of the function name instead of brackets :)

Quote
why not using the DELETE inside the FOR loop but set a bMustBeDeleted Flag?
Because using delete causes the loop to go straight to back the top and ignore anything else below it. Again, it might just be my inexperience with GLB, and I'll be able to avoid it in future.

Quote
the "player.state$" and such might be better to be an integer and constants instead of strings
Agreed, but then you have to remember 1= "menu", 2= "game" and so-on. Strings just make the code easier to read.

Quote
The code is great!
Thanks  :enc:

Offline Slydog

  • Prof. Inline
  • *****
  • Posts: 932
  • KodeSource
    • View Profile
    • KodeSource
Re: Glowing Rocks from Outer Space
« Reply #21 on: 2010-Sep-23 »
Quote
Agreed, but then you have to remember 1= "menu", 2= "game" and so-on. Strings just make the code easier to read.

You're right, using numbers in code is hard to read.  But using constants makes it clear again, such as:
Code: (glbasic) [Select]
CONSTANT STATE_MENU = 1
CONSTANT STATE_GAME = 2

SELECT player.state
CASE STATE_MENU
...
CASE STATE_GAME
...
ENDSELECT

Am I crazy, or is the 'CONSTANT' command not listed in the help file?
I was checking if you can use '%' in a constant definition, such as "CONSTANT STATE_MENU% = 1".
It doesn't give me an error, so I assume so.  It may also infer the type by the fact that is has no decimal places.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10760
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Glowing Rocks from Outer Space
« Reply #22 on: 2010-Sep-23 »
right. And put the DELETE at the end of the day, where you CONTINUE anyway.

Offline Bursar

  • Mr. Drawsprite
  • **
  • Posts: 63
    • View Profile
Re: Glowing Rocks from Outer Space
« Reply #23 on: 2010-Sep-23 »
Quote
Agreed, but then you have to remember 1= "menu", 2= "game" and so-on. Strings just make the code easier to read.

You're right, using numbers in code is hard to read.  But using constants makes it clear again, such as:
Code: (glbasic) [Select]
CONSTANT STATE_MENU = 1
CONSTANT STATE_GAME = 2

SELECT player.state
CASE STATE_MENU
...
CASE STATE_GAME
...
ENDSELECT

Am I crazy, or is the 'CONSTANT' command not listed in the help file?
I was checking if you can use '%' in a constant definition, such as "CONSTANT STATE_MENU% = 1".
It doesn't give me an error, so I assume so.  It may also infer the type by the fact that is has no decimal places.

Using the above code makes my game lock up and produces the 'not responding error'. If I replace the use of the constants with actual numbers in the CASE statements, it works. Is this a bug?

Causes lockup:
Code: (glbasic) [Select]
CONSTANT STATE_MENU = 1
state = STATE_MENU

SELECT state
CASE STATE_MENU
...
ENDSELECT

Works ok:
Code: (glbasic) [Select]
CONSTANT STATE_MENU = 1
state = STATE_MENU

SELECT state
CASE 1
...
ENDSELECT

Offline Slydog

  • Prof. Inline
  • *****
  • Posts: 932
  • KodeSource
    • View Profile
    • KodeSource
Re: Glowing Rocks from Outer Space
« Reply #24 on: 2010-Sep-24 »
Is your 'state' variable declared as an integer?  As in:
Code: (glbasic) [Select]
LOCAL state%
Other than that, that's the right way of using 'SELECT' with constants.

[Edit]
Or, if that's your entire code, then try:
Code: (glbasic) [Select]
state% = STATE_MENU
« Last Edit: 2010-Sep-24 by Slydog »
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Offline Millerszone

  • Dr. Type
  • ****
  • Posts: 307
  • www.smashedfly.com
    • View Profile
    • Smashed Fly
Re: Glowing Rocks from Outer Space
« Reply #25 on: 2010-Sep-24 »
Great game. Asteroids is my all time favorite arcade game and this one is even better!

Thanks for posting the code, I can learn a lot from it.
Hardware: iMac 27", MacBook Air, PC 3.5Ghz Quad
Developing Tools: GLBasic SDK, Gideros Studio, PureBasic
Developing for: iOS, Android, Windows, OS X, webOS, HTML5

MrTAToad

  • Guest
Re: Glowing Rocks from Outer Space
« Reply #26 on: 2010-Sep-26 »
Glad you found the TVector routine useful!