I'm a noob
Moderator: Coders of Rage
- JS Lemming
- Game Developer
- Posts: 2383
- Joined: Fri May 21, 2004 4:09 pm
- Location: C:\CON\CON
No problem, I was in a rage because I couldn't get something to work in my game, when I posted that. If you guys weren't supposed to see it I wouldn't have said anything about it. I think I'm about to move on because I just finished a theory to solve my problem. So that being said, it is possible that I will have a new vid tonight or tommorow.
Kline Out.
Kline Out.
Ok, I'm really sorry but I can't get my shurikens to work in my game.
Would anyone have any idea how to put shurikens in my game?
Blitz obviously
Here's what they need to do:
1. Fly in a direction based on your characters position
2. Only two may be on the screen (One for each player)
3.It must be deleted once off screen
I think that's all untill I put collision and what not, but I can take care if someone will help me with these shurikens.
Would anyone have any idea how to put shurikens in my game?
Blitz obviously
Here's what they need to do:
1. Fly in a direction based on your characters position
2. Only two may be on the screen (One for each player)
3.It must be deleted once off screen
I think that's all untill I put collision and what not, but I can take care if someone will help me with these shurikens.
Listen...I really don't have too much time atm, so I apologize...Usually I'd help ya out and give ya a programming lesson to teach ya teh concepts behind the code...But in this case, I'm just going to give ya the code, and hope you can figure out how it works without me having to explain it. If you have questions, post them...I'll respond when I get more time. Also, if you have problems implementing this into your program, lemme know.
To begin, lets create a new object:
Now lets create a function to create us a Shuriken...
You'd probably want to call that function somewhere else...For example...When you hit the spacebar, make a shuriken. So, you might want to have this in your input function somewhere (or something similar):
And of course you'd change the x, y, speed and direction to whatever youd' want. Try different values to see how they result until you begin to understand what it's doing. xD
Next, we'd need to make an 'update' function.
This function loops through each shuriken and checks its direction. It's assuming you gave it a value from 1 to 4...Whereas 1 is right, 2 is left, 3 is down, 3 is up. Then it adds/subtracts to the shuriken's location depending.
Next, we're going to actually need to draw each shuriken.
This function loops through each shuriken and draws a blue rectangle at each of their locations. If you'd loaded an image, then take out the 'color' and 'rect' lines, and replace them with
Finally...You said you wanted them to delete after they go off the screen (which is VERY important, or else they'll keep going forever...Wasting memory...Then eventually their integer values for their location will overload, and they'll pop back up on the other side of the screen!!! (don't ask, lol)
So let's make a bounding function:
Okay...Note the bumers. 640,480, 0, 4. What's up with those? 640,480 is what I'm assuming your screen resolution is set to (when you typed 'Graphics 640,480') and if this is wrong, change the numbers. The plus and minus 4 are for the shuriken width/height. If you use an image for the shuriken, then change the 4 to the respective correct values.
Finally....I'd make a last function for the purpose of convience:
This one isn't required...It's just there to make your code neat. It simply calls all the other functions. Now, for bullets to work, just add this one function to your main loop somewhere between your 'cls' and 'flip' statements...And be sure to actually call Make_Shuriken somewhere. ;P
Good luck, hope it helped.
To begin, lets create a new object:
Code: Select all
Type shuriken
field x,y
field speed,direction
end type
Code: Select all
;function takes a few variables, create an object, and assigns the corresponding variables to the values in the object (member variables)
Function Make_Shuriken(x,y,speed,direction)
shur.shuriken=new shurikens
shur\x=x
shur\y=y
shur\speed=speed
shur\direction=direction
end function
Code: Select all
if keyhit(57) then Make_Shuriken(player\x,player_y,6,player\direction)
Next, we'd need to make an 'update' function.
Code: Select all
function Update_shurikens()
for shur.shuriken = each shuriken
select shur\dir
case 1
shur\x=shur\x + shur\speed
case 2
shur\x=shur\x - shur\speed
case 3
shur\y=shury\y + shur\speed
case 4
shur\y=shur\y - shur\speed
end select
next
end function
Next, we're going to actually need to draw each shuriken.
Code: Select all
function Draw_shurikens()
for shur.shuriken=each shuriken
color 0,255,0
rect shur\x,shur\y,4,4,1
next
end function
Code: Select all
drawimage image,shur\x,shur\y
So let's make a bounding function:
Code: Select all
function Bound_shurikens()
for shur.shuriken= each shurken
if shur\x >= 640+4 then delete shur : exit
if shur\x <= 0 -4 then delete shur : exit
if shur\y >= 480 +4 then delete shur : exit
if shur\y <= 0-4 then delete shur : exit
next
end function
Finally....I'd make a last function for the purpose of convience:
Code: Select all
function Shurikens()
Update_shurikens()
Bound_shurikens()
Draw_shurikens()
end function
This one isn't required...It's just there to make your code neat. It simply calls all the other functions. Now, for bullets to work, just add this one function to your main loop somewhere between your 'cls' and 'flip' statements...And be sure to actually call Make_Shuriken somewhere. ;P
Good luck, hope it helped.
<qpHalcy0n> decided to paint the office, now i'm high and my hands hurt
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
You have a tendency to double-post, only click submit once, then be patient? (I fixed it again)eatcomics wrote:OMG, thank you. I was gettin close and this probably will finish it for me.
Don't worry I understand it.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.