Glowing Rocks from Outer Space

Previous topic - Next topic

Cliff3D

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

Cliff3D

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?

Bursar

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.

Cliff3D

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 :)

Kitty Hello

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!

Bursar

Thanks :)

Quotefunctions 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 :)

Quotewhy 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.

Quotethe "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.

QuoteThe code is great!
Thanks  :enc:

Slydog

QuoteAgreed, 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]

Kitty Hello

right. And put the DELETE at the end of the day, where you CONTINUE anyway.

Bursar

Quote from: Slydog on 2010-Sep-23
QuoteAgreed, 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

Slydog

#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
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Millerszone

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

Glad you found the TVector routine useful!