City Defender Problem, The Drop Bom b Code is runnign two qick!

BlitzPlus Forums/BlitzPlus Programming/City Defender Problem, The Drop Bom b Code is runnign two qick!

Tokra(Posted 2003) [#1]
I need some help please. I a designing a game I call city defender, I have the math working now for the Shooting bit, but the drop bomb code is running two fast, here the code!!

;Ok here we will draw Each of the nukes
Function DrawtheNuke()
For dropnuke.defnuke = Each defnuke
If dropnuke\nukemode=1 Then
dropnuke\nukexmod=dropnuke\nukexmod+.6
dropnuke\nukeymod=dropnuke\nukeymod+.6
Color 255,255,255
Line dropnuke\snukexmod,dropnuke\snukeymod,dropnuke\nukexmod,dropnuke\nukeymod
DrawImage dropnuke\gfxs2,dropnuke\nukexmod,dropnuke\nukeymod
ElseIf dropnuke\nukemode=2 Then
dropnuke\nukexmod=dropnuke\nukexmod-.6
dropnuke\nukeymod=dropnuke\nukeymod+ .6
Color 255,255,255
Line dropnuke\snukexmod,dropnuke\snukeymod,dropnuke\nukexmod,dropnuke\nukeymod
DrawImage dropnuke\gfxs2,dropnuke\nukexmod,dropnuke\nukeymod
End If
Next

;Ok here check to sea if the Nuke if off the screen!!!
For dropnuke.defnuke = Each defnuke
If dropnuke\nukemode=1 Then
If dropnuke\nukexmod >800 Or dropnuke\nukeymod>600 Then
Delete dropnuke
End If
ElseIf dropnuke\nukemode=2 Then
If dropnuke\nukexmod <1 Or dropnuke\nukeymod>600 Then
Delete dropnuke
End If
End If
Next

End Function

Can any one suggest a way to slow this down a bit as the bomb and the builits are always missing each other..

Here is the Bulit move code
Function movedbullet()
For playerbullet.defbullet = Each defbullet


If playerbullet\mouselockx#<=419 Then
theta#=ATan2(playerbullet\mouselocky# - playerbullet\by# ,playerbullet\bx# - playerbullet\mouselockx#)
dx#=Cos(theta#)
dy#=Sin(theta#)
playerbullet\bx#=playerbullet\bx# -dx#
ElseIf playerbullet\mouselockx#>=420 Then
theta#=ATan2(playerbullet\mouselocky# - playerbullet\by# ,playerbullet\mouselockx# - playerbullet\bx# )
dx#=Cos(theta#)
dy#=Sin(theta#)
playerbullet\bx#=playerbullet\bx# + dx#
End If
playerbullet\by#=playerbullet\by# + dy#

;Ok check To sea if the termainate point has been reached!!
;Terminate
If Int(playerbullet\bx#) = Int(playerbullet\mouselockx#) Then
If Int(playerbullet\by#) = Int(playerbullet\mouselocky#) Then
If playerbullet\Terminate=0 Then
playerbullet\Terminate=1
playerbullet\nukex=10
playerbullet\nukey=10
End If
End If
End If
Next
End Function

If any one can sugest a way to speed upone or slow the other down it be a great help.. I keep looking for the answer bye my self but I rewriten the routeans a cople of times and they seam still to be to qick or two slow.

TA
Darren (tokra)


Stevie G(Posted 2003) [#2]
Instead of using and increment of .6 in the lines of code below try something smaller like .1 - this will slow it down.

dropnuke\nukexmod=dropnuke\nukexmod+.6
dropnuke\nukeymod=dropnuke\nukeymod+.6
dropnuke\nukexmod=dropnuke\nukexmod-.6
dropnuke\nukeymod=dropnuke\nukeymod+ .6


Similarly, just multiply the variables dx and dy by .1 to slow them down.

dx#=Cos(theta#) * .1
dy#=Sin(theta#) * .1


Tokra(Posted 2003) [#3]
Thanks But that did not work, it just mesed the Math up...

If any one else can sugest a way to slow the drop bomp proc down or speed up the builit routean with out compromising the trig!!


Stevie G(Posted 2003) [#4]
Exactly what Maths has this messed up? Is there some more complex trig in another function you haven't posted which has been affected? My last post was perfectly logical based on the code you provided. If you leave the bullet code as is and reduce the ".6" increment on the nuke then the nuke will obviously move slower. That was your question - no?

I'm simply trying to help you - perhaps you should be more specific in what you would like to achieve.


Tokra(Posted 2003) [#5]
The Trig gose wrong when I make changes to the bulet code. The angles go out and do not track to the correct area of the screen... I would like a way to slow the drop nuke code down.


koekjesbaby(Posted 2003) [#6]
i would suggest exaclty the same as mister stevie g because that works. so maybe you mess things up somewhere else in your code?


Tokra(Posted 2003) [#7]
Ok I give it a try when i get home to night.

Ta


Tokra(Posted 2003) [#8]
Well I have rewriten the drop bomb code to work out the start point and then the end point then, work out the trig to move the droping bomb, it still a little qick but it better then it was and at least you can now hit the fauling nukes..

Why oh why did I choise to write this type of game i hate trig! (LOL)