making an enemy
BlitzPlus Forums/BlitzPlus Beginners Area/making an enemy
| ||
Hello I'm a new programmer and I'm having trouble with a game I wrote. In my game a bug flys around and you have to shoot it ( I know simple but it's my first game). But right now the bug flys around in this little circle and the player doesn't move. Here is the code for it: Last edited 2012 |
| ||
You need to declare x & y as Global.Global x Global y Although it would be better to use the x & y vars that are declared with the player Type. Best Regards. |
| ||
Thank you Yeshu777 it really helped. Now I have another problem :the destroying part(as I said before I'm a noob at this so I will have a lot of problems). This is what I entered for it: If(ImagesCollide(enemyimage,enemy\x,enemy\y,playerimage,x,y)) End EndIf If(ImagesCollide(enemyimage,enemy\x,enemy\y,bulletimage,bullet\x,bullet\y)) End EndIf When I put that in it gives me an error message saying "Not enough perameters" |
| ||
You have to specify frames as well:If(ImagesCollide(enemyimage,enemy\x,enemy\y,0,playerimage,x,y,0)) End EndIf If(ImagesCollide(enemyimage,enemy\x,enemy\y,0,bulletimage,bullet\x,bullet\y,0)) End EndIf |
| ||
Alright I did that but now it's giving another error message saying "variable must be a type" |
| ||
Does anybody know what that means? |
| ||
Your enemy and/or bullet type variables aren't visible where you have that code (inside a function?). As such, blitz defaults to creating the variables as integers, which is why you're being told they need to be a type when using the \ (as in enemy\x). |
| ||
Sorry I don't get it. |
| ||
Post the code you have so far and I'll try and explain things a bit better. Last edited 2011 |
| ||
I was able to figure one of the things out but now i can't shoot so this is the code so far: Last edited 2012 |
| ||
You were basically getting in a muddle with your global and type field variables. Try this: |
| ||
Thank you so much its finally working. |
| ||
Alright I have more questions :P I have just been updating the same game as before My first question is: How do I make levels? I have been trying to figure it out so the game won't compile correctly right now. My second question is: How do I get animated images in my game? I have the picture and a frame variable called already. And my last question a of right now is:Do you have any tips to organize my code? Right now it is all sloppy and I want it to look better. Thank you you have been a lot of help on this game, Simo |
| ||
Here is the code for the game: |
| ||
How do I make levels? Upload the images and sounds if you can, so we can try the game and see what the level looks like. How do I get animated images in my game? Check out the example code from LoadAnimImage it is all sloppy Last edited 2012 |
| ||
How do you upload images and sounds? |
| ||
You need to have some web space available, or use a free hosting service and upload the images and sounds in a zip file to that web space. You cannot upload files to the blitzforums themselves, but you can upload them somewhere else and link to them. |
| ||
How about I just email you, would that be okay? :P Last edited 2012 |
| ||
How about I just email you, would that be okay? :P Sorry it says it twice I accidentally resent it :P Last edited 2012 Last edited 2012 |
| ||
Matty? |
| ||
Sorry simo...I wasn't sure how to reply to your post. I don't have a PC at home and use the blitzforums from work. I rarely write programs or develop games anymore (in my spare time that is - I work as a programmer at work and try to avoid it in my spare time now) but I try to help people out on the blitzforum where I can...or discuss things in general discussion. Sorry I should have responded earlier. from Matt |
| ||
How would you do this if you wanted to make the player.player=new player inside of a function? |
| ||
function Make_Player P.Player = New Player P\X = 0 P\Y = 0 End Function I realize you posted a while ago but you didnt ever get a respponse and I can honestly say I dont know if what I said will work but If I am correct than that is all you need |
| ||
psychicbottle, your answer is correct. Although it could be inside code window :DType Player Field x,y End Type Function MakePlayer.Player() ; .Player indicates that the function returns a type-object called Player P.Player = New Player P\x = 0 P\y = 0 Return P ; If you want to continue using this player inside this function, you don't have to return it. End Function |