Well, yes, I was hoping for a certian way to organize my code. I was thinking, if the enemy type is named enemySnake, and it looks for a graphic called snake.png, and it uses the default health and speed values specified in arraySnake, then I could do stuff like this:
That way, I could reuse the same block of code to create, initialize, and check TypeEnemyTurtle, TypeEnemyFrog, TypeEnemyChicken, or whatever other kind of enemy I decided to add to my game. But I don't think Blitz will allow you to plug a variable like [id] into a part of a variable's name the way Flash did.
Anyway, looking over your code, I think it probabaly does as good a job as the technique I had planned. Using your technique, I can subclass a different type of enemy and add new behaviors and whatnot in a method unique to that enemy! In Flash, I would have wanted everything named according to what type of enemy it was, because I would need to use one function to cycle through all enemies once and then switch/cases to define their behaviors based on whether they're a snake or a turtle.
Now that I understand how subTypes and methods work in Blitz, I realize that I don't really need to automate the process of creating new variable names.
What I really need to do is to master Blitz, rather than trying to make Blitz behave the way Flash did.
Hey, this same sort of coding style for enemies would work for 3D, too, right? Just replace sprites with models and add a z-axis, right? ;)
Function loadImages() Local id:String[]=["Hero", "Turtle", "Snake"] For Local id:String=EachIn arr typeImageList.Add("images/[id].png",[id]) End Function Function spawnEnemy(x,y,id) enemy = New TypeEnemy[id] enemy.x = x enemy.y = y ListAddLast(enemyList, enemy) End Function
That way, I could reuse the same block of code to create, initialize, and check TypeEnemyTurtle, TypeEnemyFrog, TypeEnemyChicken, or whatever other kind of enemy I decided to add to my game. But I don't think Blitz will allow you to plug a variable like [id] into a part of a variable's name the way Flash did.
Anyway, looking over your code, I think it probabaly does as good a job as the technique I had planned. Using your technique, I can subclass a different type of enemy and add new behaviors and whatnot in a method unique to that enemy! In Flash, I would have wanted everything named according to what type of enemy it was, because I would need to use one function to cycle through all enemies once and then switch/cases to define their behaviors based on whether they're a snake or a turtle.
Now that I understand how subTypes and methods work in Blitz, I realize that I don't really need to automate the process of creating new variable names.
What I really need to do is to master Blitz, rather than trying to make Blitz behave the way Flash did.
Hey, this same sort of coding style for enemies would work for 3D, too, right? Just replace sprites with models and add a z-axis, right? ;)