This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2008-08-01 18:25:54

treko84
Scratcher
Registered: 2008-07-30
Posts: 5

tank game error! please help!

I am making an AI tank game, but I have a problem.
when the AI tank is moving and firing at the same time (which is often), the "bullet" stays where the tank was for about 1/2 a second while the tank keeps moving, and then goes toward the target.
Are there any Ideas as to what I may be doing wrong?

Offline

 

#2 2008-08-01 18:29:59

AlanProjects
Scratcher
Registered: 2008-06-23
Posts: 500+

Re: tank game error! please help!

i had that problem without a ai. heres a scriipt for the bullet that will fix it.
<when green flag clicked>
<forever>
<if><touching[ tank
<hide>
<else>
<show>
<end>

Last edited by AlanProjects (2008-08-01 18:30:25)

Offline

 

#3 2008-08-01 19:18:45

treko84
Scratcher
Registered: 2008-07-30
Posts: 5

Re: tank game error! please help!

I tried that, but it didn't quite work.
here are my other scripts for the bullet:
[blocks]
<when green flag clicked>
<go to[ AI turret
and:
<when I receive[ AI fire
<show>
<glide( 0.9 )secs to x sad  non AI x )y sad  non AI y
<if><touching color[ non AI color
<broadcast[ AI hit
<go to[ AI turret
<hide>
<wait( 0.5 )secsc>
<else>
<go to[ AI turret
<hide>
<wait( 0.5 )secsc>
[/blocks]

Last edited by treko84 (2008-08-01 19:19:09)

Offline

 

#4 2008-08-01 19:20:39

Bluestribute
Scratcher
Registered: 2008-01-24
Posts: 1000+

Re: tank game error! please help!

i think, when you broadcast fire, it should effect both the turret and body, giving them a slight pause


http://img247.imageshack.us/img247/1204/bluestributett4.jpg
That's my PSN ID. I know tons of COD4 glitches. Add me as your friend. Oh, and get a headset

Offline

 

#5 2008-08-09 03:34:53

SeanCanoodle
Scratcher
Registered: 2008-06-20
Posts: 100+

Re: tank game error! please help!

I see another potential problem with this script. Because you use the glide block, the bullet does not actively check to see if it hit something and will only be able to register a hit at the coordinate determined before the shot is fired. This way, to avoid being hit the player would only have to move towards the enemy tank. Try using the move block like I did with my tank AI, this way it can actively check to see if it's hit, this may also fix the firing delay issue.

Offline

 

#6 2008-08-09 09:15:26

treko84
Scratcher
Registered: 2008-07-30
Posts: 5

Re: tank game error! please help!

alright I'll try those things.
Sorry I haven't been on lately. I just got back from a 1-week vacation to see my grandparents.
the method I use for AI movement is an extended version of Sniper_rick's "tank wars" project.

Offline

 

#7 2008-08-09 09:41:55

treko84
Scratcher
Registered: 2008-07-30
Posts: 5

Re: tank game error! please help!

OK, I tried what Bluestribute suggested, but it simply made the delay before firing worse. However, I found something that did work! I just added a "go to AI turret" block at the top of the bullet's script.
I'm still working on what SeanCanoodle suggested.
Thanks everyone!

Offline

 

#8 2008-08-09 09:55:43

treko84
Scratcher
Registered: 2008-07-30
Posts: 5

Re: tank game error! please help!

hooray! it works!
Thanks to all of you!

big_smile  big_smile  big_smile  big_smile  big_smile

Last edited by treko84 (2008-08-09 09:56:28)

Offline

 

Board footer