I have been searching through it and cannot find the probel. Maybe I should just submit it to soem random Blitz dudes at the Blitz website and see what they say?
I might be best if you just posted the problem area of your code next time... it would cut down in the search and destroy crap. Hmmm... Well actually, we might need to know varaible declarations.... I don't know.
I don't know WHERE the problem is, so i could not do that. Add anyway, what good is it if you do not know if I even make certain variables global, loaded the images that I was trying to draw, ect.
Not for the first time, Marauder has stayed up with me at 12:52 and helped me sort out my garled program. Now, it went from not even displaying enemies, to generating, moving, and exploding enemies. Where all my errors were was the function enemy(). I wasn't understanding that when I typed
meant everything under it would not do anything if there were no enemies, and under it was the function to create teh enemies. There for, they wouldn't draw. The was the main problem. I alse had a few minor problems making the things explode when hit.
Next, I must make the enemies shoot.
Last edited by Guest on Sun Sep 12, 2004 12:58 am, edited 1 time in total.
Function enemy_fire()
If able_to_shoot = 1 Then
PlaySound enemy_bullet_snd
createbullet(2)
EndIf
End Function
Function createbullet(from)
If from = 1 Then
Bullet.bullet = New bullet
Bullet\x = player\x + 15
Bullet\y = player\y + 5
bullet\from = 1
bullet\frame = 0
bullet\draw = 1
EndIf
If from = 2 Then
For enemy.enemy = Each enemy
Bullet.bullet = New bullet
Bullet\x = enemy\x + 15
Bullet\y = enemy\y + 32
bullet\from = 2
bullet\frame = 0
bullet\draw = 2
Next
EndIf
End Function
Function collisions()
For enemy.enemy = Each enemy
If ImagesCollide (player_sheet,player\x,player\y,player\frame,enemy_sheet,enemy\x,enemy\y,enemy\frame) Then
PlaySound enemyexplode_snd
enemy\active = 0
explosion.explosion = New explosion
explosion\frame = 0
explosion\x = enemy\x
explosion\y = enemy\y
player\life = player\life - 20
EndIf
For bullet.bullet = Each bullet
If bullet\from = 1
If ImagesCollide (enemy_sheet,enemy\x,enemy\y,enemy\frame,small_bullet,bullet\x,bullet\y,0) Then
PlaySound enemyexplode_snd
enemy\active = 0
explosion.explosion = New explosion
explosion\frame = 0
explosion\x = enemy\x
explosion\y = enemy\y
Delete bullet
EndIf
EndIf
If bullet\from = 2
If ImagesCollide (player_sheet,player\x,player\y,player\frame,enemybullet_sheet,bullet\x,bullet\y,0) Then
Delete bullet
player\life = player\life - 5
EndIf
EndIf
Next
Next
End Function
Thanks, anyone that tried to sort this garled code..
From a quick two-second scan, I bet it's caps-sensitive. You wrote both "bullet" and "Bullet" in your code. And from what you told me about Blitz syntax, Bullet.bullet means that it should be "Bullet/from" not "bullet/from".
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
Isn't the variable in that context 'Bullet' ? That's why the first two statements work. You should try to be consistent throughout your code.
The C++ 'standard' is to name classes with a capital first letter and then use humpBack [notation]. The C 'standard' was [a] capital [first] letter and [then] '_' for spaces [instead of a capital letter immediately following where the space would be].
[Ex: (C++: theVariable, C: the_variable)]
You might consider naming your types with a capital first letter and variables with lowercase first [letter].
class PlayerTotallyOwns {
/* ... */
};
/* ... */
PlayerTotallyOwns heSureDoes;
//PlayerTotallyOwns is the user-defined variable type (ie, a class),
//heSureDoes is the variable.
Edit: Wow, I write in shorthand. Fixes for clarification are in []'s because I wanted to preserve the reason for this edit. :)
Last edited by MarauderIIC on Mon Sep 13, 2004 8:18 pm, edited 2 times in total.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
Function collisions()
For enemy.enemy = Each enemy
If ImagesCollide (player_sheet,player\x,player\y,player\frame,enemy_sheet,enemy\x,enemy\y,enemy\frame) Then
PlaySound enemyexplode_snd
enemy\active = 0
explosion.explosion = New explosion
explosion\frame = 0
explosion\x = enemy\x
explosion\y = enemy\y
player\life = player\life - 20
EndIf
For bullet.bullet = Each bullet
If bullet\from = 1
If ImagesCollide (enemy_sheet,enemy\x,enemy\y,enemy\frame,small_bullet,bullet\x,bullet\y,0) Then
PlaySound enemyexplode_snd
enemy\active = 0
explosion.explosion = New explosion
explosion\frame = 0
explosion\x = enemy\x
explosion\y = enemy\y
Delete bullet
EndIf
EndIf
Next
For bullet.bullet = Each bullet
If bullet\from = 2
If ImagesCollide (player_sheet,player\x,player\y,player\frame,enemybullet_sheet,bullet\x,bullet\y,0) Then
Delete bullet
player\life = player\life - 5
EndIf
EndIf
Next
Next
End Function
Wow, that means that the above screen shots are already inaccurate! I must be moving at a pretty good pace?
Your problem did not lay in conventions. You deleted the bullet in the following code and later tried to access it. That's like accessing a dead pointer.
If bullet\from = 1
  If ImagesCollide (enemy_sheet,enemy\x,enemy\y,enemy\frame,small_bullet,bullet\x,bullet\y,0) Then
    PlaySound enemyexplode_snd
    enemy\active = 0
    explosion.explosion = New explosion
      explosion\frame = 0
      explosion\x = enemy\x
      explosion\y = enemy\y
[color=red]Delete bullet [/color]
  EndIf
EndIf
 Â
If bullet\from = 2
  If ImagesCollide (player_sheet,player\x,player\y,player\frame,enemybullet_sheet,bullet\x,bullet\y,0) Then
      Delete bullet
      player\life = player\life - 5
  EndIf
EndIf
Only delete tpye instances at the end of the loop.
Small girl at the harbor wrote:Look Brandon, that crab's got ham!
Wow, you're right, JS lemming, lol. That fixes another problem I was having but didn't yet post, lol. Anyway, I don't actually have a problem right now, but but I do have a few questions. In Blitz, how do you make something return a value without just giving an error? For example, if I try to open the high scores that are in a text document, and it is the first time running the program and there ISN'T a high score file, how would I make it not give an error and shut the program down, but instead print something to the screen or create one?
Oh, and JS Lemming, if you happen to read this, are you okay on the weekend for the interview?
;if file blaa.txt does not exist, create it
If FileType("blaa.txt") = 0
tempfile = WriteFile("blaa.txt")
CloseFile(tempfile)
Else
tempfile = OpenFile("blaa.txt")
; do stuff
CloseFile(tempfile)
EndIf
yeah sure I'm up to the interview. Hopefully.
Small girl at the harbor wrote:Look Brandon, that crab's got ham!