Bullets/Collision

BlitzMax Forums/BlitzMax Beginners Area/Bullets/Collision

Zacho(Posted 2009) [#1]
Can someone look @ this code and tell me what I need to add to create bullets and update them. And also add collision detection with the bullets and the enemies.

What this code does is when the user hits the 'S' key, a bullet is drawn @ 0,0. If the 'S' key is released, the bullet is not drawn.





amonite(Posted 2009) [#2]
Here is a quick code that won't run as is but maybe it can help you
see how this could be done.

Global b:TBullet
Global bullet_list:TList = New TList 
Global bullet_img:TImage = LoadImage("yourbulletimage.png")



Type TBullet
	Field x:Float
	Field y:Float 
	Field sx:Float 
	
	Function init:TBullet(_x:Float, y_:Float, _sx:Float)
		b:TBullet = New TBullet 
		b.x = _x
		b.Y = _y
		b.sx = _sx
		ListAddLast bullet_list, b
	EndFunction 
	
	Method draw()
		DrawImage bullet_img, x, y, 0
	EndMethod 

	Method refresh()
		If KeyHit(KEY_S)
			TBullet.init(player.x, player.y, 8)
		EndIf 
		x:+sx 
		If x >= 640 ListRemove bullet_list, b
		If ImagesCollide(bullet_img, x, y, 0, enemy_img, enemy.x, enemy.y, 0)
			ListRemove bullet_list, b
			'do something
			'...
		EndIf 
	EndMethod 

EndType 



Graphics 640,480

	While KeyHit(27)<> 1
		Cls 
		For b:TBullet = EachIn bullet_list
			b.refresh()
			b.draw()
		Next 
		Flip 
	Wend 
	
	End 



Jesse(Posted 2009) [#3]
@zacho
I don't know how you got your code to work but it is completely ilogical. I tried to make some sence and just could not get head from tail. this for example:
masterC_MasterChief = New MasterChief
masterC_x = 34
masterC_y = 575
masterC_frame = 0
masterC_health = 100

it doesn't make sence. i think you are trying to process it kind of like in BlitzBasic and it doesn't qute work that way.
and what about this:
If KeyHit(KEY_J) Or KeyDown(KEY_J)

I don't think there is a need for both of them but I could be wrong. the keydown will supersede the keyhit.

Understand I am not trying to pick on your code but it kind of makes it hard to help you if yourself don't understand what you are doing. I sugest you go through some tutorials first so you can get the basics. I recomend you read these ones:
http://www.blitzmax.com/Community/posts.php?topic=42519
http://www.blitzmax.com/Community/posts.php?topic=59233
if you still want to do it on your own. Start from something simple such us moving an object with the keyboard. once you have that, integrate a self moving object. the self moving object is the basics for a bullet. next step is figuring out collition.
post your simple work in progress and I if not somebody in here will be able to help you.

P.S get used to using "Superstrict" at the begining of your code. if not atleast "Strict".


Zacho(Posted 2009) [#4]
@Neji-Ok, your example will probably do it (haven't tested it yet). The reason I asked about an example for projectiles and updating it was that I kept on getting a compile error "Compile Error: ForEach must be used with a string, array, or appropriate object" with my 'try' on creating bullets. Your example seems to make sense with me :). One question though, what is does the <>1 mean in
While KeyHit(27)<> 1
Edit: Found out. While Keyhit(27) does not equal 1 or is false. Ok, got that down! :) That's the only part I didn't understand. Btw: Do I have to put the capital T in the places you mentioned in your code? Or is it ok if I just take em' out? Also, do I have to put the type and other code before I initiate graphics mode?

@Jesse-Well Jesse, here's how I work. I first bought a blitzbasic demo awhile back and only had the demo version for quite some time. The demo didn't have many features so I stuck with pretty basic stuff (pun intended). That is why I don't use Strict or Superstrict because I usually declare a variable @ 0 before I declare it at something else. As for the code you mentioned:
masterC_MasterChief = New MasterChief
masterC_x = 34
masterC_y = 575
masterC_frame = 0
masterC_health = 100


These are the values of my avatar before the main loop begins. X value @ 34, y value @ 575, frame @ 0, and health @ 100.

And...
 If KeyHit(KEY_J) Or KeyDown(KEY_J)


That is there if the player just wants to tap the key to perform an action. I don't want the extra time that is needed for keydown. Might sound silly, but that's the way I have it. :)


Zacho(Posted 2009) [#5]
Hold on a sec... What do I do here?

Global b:TBullet
Global bulletSlist:TList = New TList 
Global bulletSnipe:TImage = LoadImage('Cutout")

Type MasterChief
	Field x,y      
	Field frame
	Field health
End Type
Type AquaTurtle
	Field x,y
	Field frame
	Field health
EndType 

Type TBullet
	Field x:Float
	Field y:Float 
	Field sx:Float 
	
	Function init:TBullet(_x:Float, y_:Float, _sx:Float)
		b:TBullet = New TBullet 
		b.x = _x
		b.y = _y
		b.sx = _sx
		ListAddLast bulletSlist, b
	EndFunction 
	
	Method draw()
		DrawImage bulletSnipe, b.x, b.y, 0
	EndMethod 

	Method refresh()
		If KeyHit(KEY_S)
			TBullet.init(masterC_x, masterC_y, 8)
		EndIf 
		x:+sx 
		If x >= 640 ListRemove bulletSlist, b
		If ImagesCollide(bulletSnipe, ???x, ???y, 0, aquaIdle, aqua.x, aqua.y, 0)
			ListRemove bulletSlist, b
			'do something
			'...
		EndIf 
	EndMethod 

EndType 


Right here: If ImagesCollide(bulletSnipe, x, y, 0, aquaIdle, aqua.x, aqua.y, 0)
what do I put in these locations? [Look @ the ? marks]


Zacho(Posted 2009) [#6]
Nvm... I got my program to run. Run, not work. I still cannot see bullets created. Here is the code:


Global b:TBullet
Global bulletSlist:TList = New TList 
Global bulletSnipe:TImage = LoadImage("myimage")

Type MasterChief
	Field x,y      
	Field frame
	Field health
End Type
Type AquaTurtle
	Field x,y
	Field frame
	Field health
EndType 

Type TBullet
	Field x:Float
	Field y:Float 
	Field sx:Float 
	
	Function init:TBullet(_x:Float, y_:Float, _sx:Float)
		b:TBullet = New TBullet 
		b.x = _x
		b.y = _y
		b.sx = _sx
		ListAddLast bulletSlist, b
	EndFunction 
	
	Method draw()
	'	If KeyHit(KEY_S)
		DrawImage bulletSnipe, b.x, b.y, 0
	'	EndIf
	EndMethod 

	Method refresh()
	'	If KeyHit(KEY_S)
			TBullet.init(masterC_x, masterC_y, 8)
	'	EndIf 
		x:+sx 
		If x >= 640 ListRemove bulletSlist, b
'		If ImagesCollide(bulletSnipe, b.x, b.y, 0, aquaIdle, aqua.x, aqua.y, 0)
'			ListRemove bulletSlist, b
			'do something
			'...
	'	EndIf 
	EndMethod 

EndType 


The imagescollide I commented out so the program would run. But anyways would I add change anything to this section of code to create the bullet?

'
' S N I P E R
If KeyHit(KEY_S) Or KeyDown(KEY_S)
	masterSnipeR=1

	masterC_frame = masterC_frame + 1
	'draw()
	If masterSnipeR = 1 And masterC_frame > 2
		masterC_frame = 0
	EndIf	
	
	Else
	masterSnipeR=0
EndIf 



Azathoth(Posted 2009) [#7]
Are you using Strict? That should help you with your variable names.


Jesse(Posted 2009) [#8]
Global bulletSnipe:TImage = LoadImage("myimage")

Type MasterChief
	Field x,y      
	Field frame
	Field health
End Type
Type AquaTurtle
	Field x,y
	Field frame
	Field health
EndType 


Type TBullet
	Field x:Float
	Field y:Float 
	Field dx:Float
	Field dy:Float
	Field speed:Float 
	Global bulletSlist:TList = New TList 
	
	Function init:TBullet(_x:Float, _y:Float, _dx:Float,_dy:Float,_speed:Float)
		b:TBullet = New TBullet 
		b.x = _x
		b.y = _y
		b.dx = _dx
		b.dy = _dy
		b.speed = _speed
		ListAddLast bulletSlist, b
	EndFunction 
	
	Function draw()
		For Local b:Tbullet = EachIn bulletSlist
			DrawOval b.x,b.y,3,3 'DrawImage bulletSnipe, b.x, b.y, 0
		Next
	EndFunction 

	Function refresh()
		For b:TBullet = EachIn bulletSlist
			
			b.x :+ b.dx * b.speed
			b.y :+ b.dy * b.speed
			
			If b.x >= 640 ListRemove bulletSlist, b ; Continue
			If b.y >= 480 ListRemove bulletSlidt, b ; Continue
			
		
			'If ImagesCollide(bulletSnipe, b.x, b.y, 0, aquaIdle, aqua.x, aqua.y, 0)
			'	ListRemove bulletSlist, b
			'	'do something
				'...
			'EndIf
		Next
		
		
	EndFunction 

EndType 

Graphics 640,480
Repeat
	Cls
	If KeyHit(key_space) Tbullet.init(10,300,1,0,1)
	Tbullet.refresh()
	Tbullet.draw()
	DrawText "press spacebar to shoot",0,10
	DrawText "number of bullets alive "+(Tbullet.bulletSlist.count()),0,25
	Flip()
Until KeyDown(key_escape)


let me know what you don't understand and I will try to explain it to you.


Zacho(Posted 2009) [#9]
@Azathoth - No. I don't use Strict

@Jesse- Thanks. I'll try out the code later ok? I have things to do today.


Brucey(Posted 2009) [#10]
No. I don't use Strict

You should really at least use Strict. (If not SuperStrict).
It will help you with all kinds of basic problems - like setting up your variables, etc.


Zacho(Posted 2009) [#11]
Ok, its getting better. First I will post the code.
Type TBullet
	Field x:Float
	Field y:Float 
	Field dx:Float
	Field dy:Float
	Field speed:Float 
	Global bulletSlist:TList = New TList 
	
	Function init:TBullet(_x:Float, _y:Float, _dx:Float,_dy:Float,_speed:Float)
		b:TBullet = New TBullet 
		b.x = _x
		b.y = _y
		b.dx = _dx
		b.dy = _dy
		b.speed = _speed
		ListAddLast bulletSlist, b
	EndFunction 
	
	Function draw()
		For Local b:Tbullet = EachIn bulletSlist
			'DrawOval b.x,b.y,3,3 'DrawImage bulletSnipe, b.x, b.y, 0
			DrawImage bulletSnipe, b.x, b.y, 0
		Next
	EndFunction 

	Function refresh()
		For b:TBullet = EachIn bulletSlist
			
			b.x :+ b.dx * b.speed
			b.y :+ b.dy * b.speed
			
	'		If b.x >= 640 ListRemove bulletSlist, b ; Continue
	'		If b.y >= 480 ListRemove bulletSlidt, b ; Continue
			
		
			'If ImagesCollide(bulletSnipe, b.x, b.y, 0, aquaIdle, aqua.x, aqua.y, 0)
			'	ListRemove bulletSlist, b
			'	'do something
				'...
			'EndIf
		Next
		
		
	EndFunction 

EndType 

And
 '
' S N I P E R
If KeyHit(KEY_S) Or KeyDown(KEY_S)
	masterSnipeR=1
'	DrawImage haloSnipeR, masterC_x, masterC_y, masterC_frame
	masterC_frame = masterC_frame + 1
	Tbullet.init(masterC_x,masterC_y,1,0,1)
	Tbullet.refresh()
	Tbullet.draw()

	If masterSnipeR = 1 And masterC_frame > 2
		masterC_frame = 0
	EndIf	
	
	Else
	masterSnipeR=0
EndIf


These pieces of code finally draw the bullet image! YES!! But....it is only drawn when the 'S' key is hit. If the 'S' key is hit, the image is drawn. On the other hand, if the 'S' key is held down, many bullets are created. [The only way I figured this out is when I jumped and saw them coming out @ the different y values.] ((If the S key isn't held or hit, the bullets aren't drawn))

The only few things this code needs is:
-an updater {to update bullets}
-collision detection

And then I will finally be getting somewhere on my program!!


Jesse(Posted 2009) [#12]
what I see here is a lack of the ability to think logically :). I am not going to tell you the answer because you need to learn to do that by yourself. The answer is really simple. I will give you hints hopefully you can get it but if somebody gives you the answer, oh well.
follow:
if you put something in an if statement, only when the condition is true will it be executed. In the code above in your last if statement everything will get executed only when you press a key. In other words no logic, no drawing and no creation of objects is executed until a key is pressed. Now, if you have a loop that allows continuous execution of that if instruction for say 15 seconds and the condition does not change, there will be nothing displayed for 15 seconde, no logic executed and nothing created. what you want is to continue moving the bullets previously created and continue drawing them whether you press a key or not. the question is, why are you including everything in an if statement? in other words, why are you stopping everything until a key is pressed?

you need to try to figure that out. it's not that hard.

P.S. another hint

-an updater {to update bullets}


Refresh and update are the same thing in your code.


Zacho(Posted 2009) [#13]
Wow. I can't believe I didn't see that Jesse. Duh to me! Lol. I figured it out. I just took out the
Tbullet.refresh()
out of the If statement and put it in the main loop. I'm so happy I got this problem solved :) :). But one question (until I think of another one :)), what is the letter 'T' used for in all of my code? Does a letter 'T' have to be there, or could I just take it out?


Azathoth(Posted 2009) [#14]
@Azathoth - No. I don't use Strict
Then you should. I'm not a big fan of SuperStrict, but I will use Strict when my code starts getting complicated.


Jesse(Posted 2009) [#15]
"Tbullet" is your "type". to access functions directly with out having to create an instance of TBullet, use the name of your type 'dot' and the name of the function in the type. you can create an instance outside the main loop such as :
shot:Tbullet = new Tbullet

then replace
Tbullet.init()
Tbullet.refresh()
Tbullet.draw() 


with this:
shot.init()
shot.refresh()
shot.draw()



Zacho(Posted 2009) [#16]
what about TList? Can I replace TList with any other name as I want?


Jesse(Posted 2009) [#17]
no, you can not rename types. you can only create instances of it with whaever name you want:
local shot:Tbullet <- shot is an instance of Tbullet

local bullet:Tbullet <- bullet is an instance of Tbullet

local list:Tlist <- list is an instance of Tlist

local carList:Tlist  <- carList is an instance of Tlist 


no kidding, you really need to go through those tutorials I mentioned in post #3.


Zacho(Posted 2009) [#18]
No, I mean instead of typing in
Global b:TBullet
Global bulletSlist:TList = New TList 
Global bulletSnipe:TImage = LoadImage("myimage")


I would type in perhaps...
Global b:XBullet
Global bulletSlist:QList = New QList
Global bulletSnipe:IOImage = LoadImage("myimage")


About the tutorials, I will read them eventually. Don't think I will just toss em'. They are nice tutorials. I just don't have the time atm.


Jesse(Posted 2009) [#19]
no, but you can do:
Type XBullet extends TBullet
End type

Type QList extends Tlist
End Type

then do:
global b:XBullet
global bulletSlist:QList = new Qlist


Carefull though, you really need to know what you are doing to do it this way. some commands are not going to work with the extension with out a work around. You're trying to run before you can walk. :)


Zacho(Posted 2009) [#20]
Oh ok, I was just wondering. :)

Could you look @ post #5? I'm also wondering how to do collision detection. I've tried using the _ and . between b and x but neither work.


@ Neji- Hey Neji. I don't know if you are reading this thread anymore but your bullet example really helped me. Thanks!


Zacho(Posted 2009) [#21]
Uh...anyone there?


Zacho(Posted 2009) [#22]
Can anyone also help with collision detection in my code?


Gabriel(Posted 2009) [#23]
You've ignored a lot of the advice given to you and made it clear that you "don't have time" to learn how to fix your code. I think you'll find a lot of people will struggle to find time to fix your code for you when you can't find time yourself.

The only advice I "have time" to offer at the moment is to reconsider your decision not to use SuperStrict because it will resolve a number of errors I can see in your code.


Zacho(Posted 2009) [#24]
I've been a jerk haven't I?
I'm so sorry I am only asking "what should I type" instead of "I need help, could someone give me a few pointers?" Truth is I'm making a game for my friends and I don't want to spend too long on the code so I can get furher in my game. So I just thought I could ask 'round here, get the code, and be done. But I now realize that I was acting foolish, selfish, and lazy.

How 'bout we can start over? Hi, I'm Zacho!

About SuperStrict, I'm not going to use that because everything in my program works atm. I feel that adding SuperStrict would complicate my program (which I don't want).


Gabriel(Posted 2009) [#25]
No, you haven't been a jerk. You've been what we all can be at times. You've been a bit focused on the end result and you've lost sight of how you get there a little bit.

Anyway, I assume you're editing your above post as I type this because the sentence about why you're not using superstrict is half-finished. I'll assume you have a good reason and tell you what SuperStrict would have told you.

I'm looking at bits of code like this:

masterC_MasterChief = New MasterChief
masterC_x = 34
masterC_y = 575
masterC_frame = 0
masterC_health = 100


Now I think people have skipped over this before because you're apparently still unsure whether you need a . or a _ to access fields. Let me explain what you're doing above.

You create a new object of Type MasterChief and put it in a variable called "masterC_MasterChief". You don't need that _MasterChief on the end of the variable name. I think you've added that because you think it's part of the syntax, but it's not necessary and you've just made it part of the variable name. If you want to specify that masterC is a MasterChief object, declare it using a semicolon : between masterC and MasterChief (example below)

Then you create new variables called masterC_x, masterC_y, masterC_frame and masterC_health. I *think* you want to use the fields of your masterC object. But you can't because your masterC variable is actually called masterC_MasterChief and because . is the correct syntax to access a field.

I think what you're trying to do would be better achieved with this code:

Global masterC:MasterChief = New MasterChief
masterC.x = 34
masterC.y = 575
masterC.frame = 0
masterC.health = 100


If you had SuperStrict on it would have indicated you were using variables you hadn't declared and you probably would have solved it a lot quicker.

So yes, you should be using . to access fields of types, not an underscore. Now if you want some help on this collision problem, can you at least post a full version of the code which is updated with everything Jesse and the others helped you with above, and if you've understood it what I've just explained here.

At the moment, I'm not clear on what your current code looks like in full.


Zacho(Posted 2009) [#26]
I'd love to post my code for all of you. I'm glad that you understand my situation (of being lazy and selfish and all) and realise and post that everyone has this happen to them. Makes me feel like I'm not the black cow in the meadow... anyway here is my updated code. Everything works currently:



As with you said with the . <-- using that to declare variables and such. Glance over this code
' S N I P E R     B U L L E T
Type TBullet 
	Field x:Float
	Field y:Float 
	Field dx:Float
	Field dy:Float
	Field speed:Float 
	Field timer = MilliSecs()+1100
	Global bulletSlist:TList = New TList 
	
	Function init:TBullet(_x:Float, _y:Float, _dx:Float,_dy:Float,_speed:Float)
		b:TBullet = New TBullet 
		b.x = _x
		b.y = _y
		'b.dx = _dx
		'b.dy = _dy
		b.dx = 70
		b.dy = _dy

		b.speed = _speed
		ListAddLast bulletSlist, b
	EndFunction 
	
	Function draw()
		For Local b:Tbullet = EachIn bulletSlist
			DrawImage bulletSnipe, b.x, b.y, 0			
		Next
	EndFunction 

	Function refresh()
			
		For b:TBullet = EachIn bulletSlist
			DrawImage bulletSnipe, b.x, b.y, 0
			
			b.x :+ b.dx * b.speed
			b.y :+ b.dy * b.speed
			
			If b.x >= 800 ListRemove bulletSlist, b ; Continue
	'		If b.y >= 480 ListRemove bulletSlist, b ; Continue
			
		
			If ImagesCollide(bulletSnipe, b.x, b.y, 0, aquaIdle, aqua.x, aqua.y, 0)
			'	ListRemove bulletSlist, b
			'	'do something
				'...
			EndIf
		
		Next
			
		
	EndFunction 

EndType 


And run the program I get a compiler error 'Identifier 'x' not found'. [It's the line with 'ImagesCollide']. This is why I was asking previously whether to use a . or _ and I don't know if SuperStrict would help fix this issue.

One last question for now :).... are there SetImageFont example in the code archieves? If you don't know offhand than don't answer. I can find this answer by myself :).


Jesse(Posted 2009) [#27]
how funny, you have all of these types and you are not using a single one except the one that was given to you. At the rate you are going, you are going to finish the game and you would have learned nothing.:). I don't want to be mean but I have to tell you that I will not help you until you figure out how to uset types. I mean read the OO T*U*T*O*R*I*A*L!. if you have something to prove to somebody it's going to have to wait until you learn the basics. you say, you are working on another game. If you are using the same logic, you have some serious problems coding. Nobody here is going to help you if you are not willing to learn.

you have obviously shown you are no genious at coding so why do you want to make a game without learning the basics. the code Neji posted should have been enough for you to learn how to use the type or at least to learn wheather to use '_" or ".".

GO READ! and when you have understood the types you created. Comeback and ask some INTELLIGENT questions. All I hear right now is "Can you make my game so I can get credit for it." nobody here has that time or is that generous. I like showing others how to do stuff but I get inpatient when there is no interest in learning. ;)


Azathoth(Posted 2009) [#28]
You really should consider using Strict, your code is a mess.


amonite(Posted 2009) [#29]
@Zacho, for the SetImageFont, you must use it after your Graphics command.

And run the program I get a compiler error 'Identifier 'x' not found'. [It's the line with 'ImagesCollide'].


Because you should have a type declared for your aqua instance.

Again, use superstrict, read the tutorials :)


Zacho(Posted 2009) [#30]
@ Jesse - Jesse, did you read post #24? I'm sorry, ok! I already stated that I was acting selfish and lazy and all of that. Btw: the only question I have asked since that post was if there was a SetImageFont example. Don't have to be so harsh...

The book I got that is about BASIC isn't the best alright! It provided only ONE example. And that example was a shooter. And here's what program it was for BLITZ BASIC! I'm not familiar with the more-complex language of blitzmax yet. Please let me learn slowly. Don't throw all of these insults 'READ IT', 'LEARN IT','Why are you asking dumb questions', and etc. I'm not perfect

Just a reminder that this post is in the beginners section ok...

@ Azathoth - Ok. I haven't heard that before... Lol

@ Neji - Thanks Neji. It seems to me like I'm getting only positive feedback from you. Thanks a bundle!


Zacho(Posted 2009) [#31]
Ok, you got me. I really don't know how to program 'correctly'. I just work off examples. If I happen to see an example of how to create a sprite (by creating a type and assigning a value and image to that type) than that's what I do. I don't know how to use method, arrays, and most of the rest of the functions. I don't know when to use a colon over a period or a period over a underscore. I never learned that. I'm just trying to make my life more exciting by making a game and getting recognized. I've never been the popular person, always behind the sceens guy and never really got attention and stuff. When I registered, I was hoping I could get help with all of my programming issues, but it seems that I can't get help because I don't know enough. So, I'd like to say thanks @ least to Neji and Jesse. Neji for giving me framework for creating bullets and Jesse for coaching me through it before you got harsh...

I realize that to everyone that my code is messy. To me, it looks fine. I'm a person who doesn't like to use functions and complicated stuff, because I don't know how it works. That's the kind of guy I am, I need to KNOW how something works and then I will understand it. So when I get replies like "Because you should have a type declared for your aqua instance." I understand that because it is simple enough to see that you need to create a aqua type before using the function. But when you say something like this:
Global b:TBullet
Global bulletSlist:TList = New TList 
Global bulletSnipe:TImage = LoadImage("myimage")


I don't understand what the colon does, and how everythings related, see? After reading this you will prolly' say "Jeez, then read some material to understand all of this stuff". And I will, it just takes me [personally] a longer time to grasp material. So...if your sick of me already, then just go.... I don't have time for negative comments...I can program the way I want...

Truth is, I don't have the best life. I could go on and on of how many things I would like to change in my life............. I'm wanting to learn a skill (that I think is the right one for me) so if you don't have the code or time to help me than just give me some encouragement ok? Not even an example, encouragement could really help me out right now. Don't bother typing 'Use Strict, your code is a mess', just say nothing @ all ok? I don't need negative comments @ this time of my life.


Gabriel(Posted 2009) [#32]
Global b:TBullet

This says I would like to declare a global object. I would like to use the variable b to refer to my object. The object will be an instance of the TBullet type. Currently I do not wish to create an object.

Global bulletSlist:TList = New TList

This says I would like to create a global object. I would like to use the variable bulletSlist to refer to my object. The object is an instance of the TList type. I would like to create my object right away.


Global bulletSnipe:TImage = LoadImage("myimage")

This says I would to create a global object. I would like to use the variable bulletSnipe to refer to my object. The object is an instance of the TImage type. I would like to immediately call a function called LoadImage (which I happen to know will create a new TImage) and returns my new object.

Any of that make sense? Any parts not make sense? Any clarification needed?


Zacho(Posted 2009) [#33]
Now THIS is what I need!! Perfect Gabriel. Perfect!! Now how bout' the rest of my code? Lol :)


Jesse(Posted 2009) [#34]
Bad Jesse! Bad Jesse! sorry?
Most of us here don't have that much free time and to explain something that there is a quick tutorial you can use as reference, it's a waste of time for me and others. It is taking you just as long if not longer for us to explaint that to you than it woud take for you to go through the tutorials. If I explain all of that to you like Gabriel did I probably wouldn't do as good of a job as the tutorials and you would be left with more questions.

Taking advice, taking one step at a time like learning to use something before you use it, doing simple code with what you are learning are all ways to progress in your skills one step at a time. Jumping head on in to a game with out any skills it's just suicide. I admit it's brave of you and possible but bery rare.

Don't worry sence you have your way of doing things and I have my way and they both clash, I won't post here I am shure there are others here who think the same way you do and who can help you and do a better job at it then me and have more patience and time.

Admiting and letting others know you have personal problems doesn't cure you, doing something about it does. If you are having personal problems I am sorry for you. I wish you the best with them but as far as programming goes I stand my ground.

Good luck with your game! and excuse my harshness.


Zacho(Posted 2009) [#35]
Ya. I think we both got on each other's turf. I was to simple for you, and you were too complex for me (in programming terms of course). I'll read some tutorials right now....ok?


Zacho(Posted 2009) [#36]
I just started to read the OO tut. It's makin sense to me. Although I will have to read it again to nail it down. I can see why you call my code 'messy' now. :)


Nate the Great(Posted 2009) [#37]
Ok, you got me. I really don't know how to program 'correctly'. I just work off examples. If I happen to see an example of how to create a sprite (by creating a type and assigning a value and image to that type) than that's what I do. I don't know how to use method, arrays, and most of the rest of the functions. I don't know when to use a colon over a period or a period over a underscore. I never learned that. I'm just trying to make my life more exciting by making a game and getting recognized. I've never been the popular person, always behind the sceens guy and never really got attention and stuff. When I registered, I was hoping I could get help with all of my programming issues, but it seems that I can't get help because I don't know enough. So, I'd like to say thanks @ least to Neji and Jesse. Neji for giving me framework for creating bullets and Jesse for coaching me through it before you got harsh...


haha thats not at all uncommon for many programmers to start out not knowing what anything means and doing things the brute force way or the wrong way altogether without functions or types... as for the personal stuff.. that was deep but keep in mind, we really dont know you, only you and your friends and family know you so only you and your friends and family can help you with that. :) Its all just a stage in adolescence anyway.

Back to the point. I started out brute-force and copy-pasting most of my code a few years ago. I didnt get functions until I moved to blitz and I didnt get types until about that time either. It all takes a lot of time and practice. It is probably good for you to brute force some things now because you will learn what to brute force and what not to in the future. If you copy-paste, try to understand what you are copying. Every time I copy-paste anything wich is pretty rare now, I always read through it and try to understand it. Im not saying I am perfect at any of these, I am in no way perfect and there may be many things I still dont understand or get about programming. If there is still anything you dont get about functions, types, lists, etc then please ask again because this thread is so long and confusing, it is hard to seperate what you get now from what you dont get.


Zacho(Posted 2009) [#38]
I'm pretty much ok right now. And about being
deep
it feels good to let it all go once in a while, you should try it sometimes. It really makes you feel better.

Anyway the only question I still have is from post #26; the ImagesCollide function. Would I create the aqua type and declare it before the "ImagesCollide" command is processesed so the compiler recognizes the identifier x? That's the only last question I have left. I will make new threads if I have more questions. I agree, this thread is a little long and confusing. Lol :)