Page 2 of 2

Posted: Sat Sep 11, 2004 10:57 pm
by Guest
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.
lol cool 3dish
3 "dish" O.o
3D-ish ? o.o

Posted: Sun Sep 12, 2004 12:58 am
by Guest
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

Code: Select all

for enemy.enemy = each enemy
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.

Posted: Sun Sep 12, 2004 1:34 am
by MarauderIIC
12:52 in *your* time zone :) 1:52 here.

Posted: Mon Sep 13, 2004 4:36 pm
by Guest
OMG. As usual, I have ANOTHER problem. i would appreciate any help i can get.

The problem is, when in debug mode, my game randomly shots off and highlights

Code: Select all

If bullet\from = 2
from my collision function, and an error box appears that says: object does not exist. Here's all of the code that i think may be screwed up:

Code: Select all

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

Posted: Mon Sep 13, 2004 7:19 pm
by MarauderIIC
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".

Posted: Mon Sep 13, 2004 7:42 pm
by Guest
In differnt functions I did:

Code: Select all

For Bullet.bullet = each bullet
BUT, in the end of those functions, I also wrote:

Code: Select all

Next
ending that loop. But in a DIFFERNT function (collisions), I wrote:

Code: Select all

For bullet.bullet = Each bullet 
not capital.
So that cannot be the problem....can it?

Space invaders

Posted: Mon Sep 13, 2004 8:18 pm
by MarauderIIC
As long as you were consistent within the context (look that one up).

You were inconsistent here:

Code: Select all

Bullet.bullet = New bullet
   Bullet\x = enemy\x + 15
   Bullet\y = enemy\y + 32
   bullet\from = 2
   bullet\frame = 0
   bullet\draw = 2
Next
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].

For example,

Code: Select all

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

Posted: Mon Sep 13, 2004 8:54 pm
by Guest
You're right, Marauder. Iw as looking at a differnt place. sorry.

Anyway, I'm not AS dumb as I thought. I got it to work! This is what my completed function looks like now, incase any of you want to know:

Code: Select all

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?

Posted: Tue Sep 14, 2004 7:33 am
by JS Lemming
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.

Code: Select all

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.

Posted: Tue Sep 14, 2004 4:55 pm
by MarauderIIC
Neat, last I heard he had it working :) But yeah, that's probably more it than caps-sensitiveness.

Posted: Fri Sep 24, 2004 9:40 am
by Guest
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?

Posted: Fri Sep 24, 2004 7:18 pm
by JS Lemming
For the error checking use command FileType.

Code: Select all

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