A few other mysteries you talked about that I can hopefully dispel:
1. If you declare send distances in
function LevelSetup(), and then declare them again in function
LevelLogic(), the values in
LevelLogic() will overwrite those in
LevelSetup() the moment the game starts.
2. You identify individual asteroids either with a variable, or with their ID.
For example, consider this code:
function LevelSetup()
-- Bunch of globals..
-- Asteroid #0
fluffy = AddAsteroidWithAttribs(250,-350,0.5,0.5,0.3)
-- Asteroid #1
battlefluffy = AddAsteroidWithAttribs(250,-350,0.5,0.5,0.3)
Now I can refer to the first asteroid as either "fluffy" or "GetAsteroid(0)", and I can refer to the second asteroid as either "battlefluffy" or "GetAsteroid(1)".
So for example, to continue from the above code, we could set the following send distances and radiuses:
function LevelSetup()
-- Bunch of globals..
-- Asteroid #0
fluffy = AddAsteroidWithAttribs(250,-350,0.5,0.5,0.3)
fluffy.SendDistance = 1200
GetAsteroid(0).radius = 300
-- Asteroid #1
battlefluffy = AddAsteroidWithAttribs(250,-350,0.5,0.5,0.3)
GetAsteroid(1).SendDistance = 1450
battlefluffy.radius = 375
You can mix and match variables and the GetAsteroid command in this way. It's just two different methods of referring to an asteroid, and both are "compatible" with everything else.
As for the ID numbers,
the order in which asteroids are created is what determines what their ID numbers shall be. The first asteroid you create is asteroid ID 0, the second is ID 1, etc.
3. Regarding the drawing of lines on the screen. It's not obvious, because it is not covered in any tutorial (I'm saving it for an "Advanced" tutorial). But since you talked about it in your post, I'll talk a little about how you draw things now.
First of all it's important to understand that you don't put DrawLine or DrawSprite commands in LevelSetup or LevelLogic.
Instead, they go in their very own function! You have a choice, you can either draw to the level or to the screen - using either
function LevelDraw() or
function ScreenDraw().
Lets take a look at an example:
function LevelSetup()
-- bunch of globals
-- Asteroid #0
a = AddAsteroidWithAttribs(0,0,0,0,0)
end
function LevelDraw()
DrawLine(50,50,200,200,0,1,0,1,0,0,1,0.5,5)
end
function LevelLogic()
end
That would draw a line.
The way the DrawLine command works is it draws a line from Point 1, to Point 2. You set the coordinates of Points 1 and 2, and various properties about them; you specify the colour of each end of the line, and the "alpha", which is how transparent it is. That means you can create lines with cool crossfades of colour. Finally, you set how thick the line should be.
Here's what all the parameters are:
DrawLine(X-Coord 1, Y-Coord 1, X-Coord 2, Y-Coord 2, Red 1, Green 1, Blue 1, Alpha 1, Red 2, Green 2, Blue 2, Alpha 2, Line Thickness)
Hope that explains it. Let me know if you still can't get that to work, and I'll do a proper playable map. :>
4.
I look forward to the time when I can concentrate on tweaking AI behaviour and working out elegant mathematical solutions to my codes, but it is frustrating at this point as that is something that seems to be far in my future.
I realise it's frustrating with the initial problems, but right now you are going through an important process of learning how to analyse the code you've written and look for mistakes. Some of the things you've talked about, the discovery that asteroid ID's start with 0 instead of 1, these are crucial lessons which will stand you in good stead for all of your coding going forward. :> It really doesn't take as long to get up to speed as you'd imagine.
We're here to help! So if you get stuck or if you have a random question about something, just let us know. :>