Qbasicnews.com

Full Version: small shooter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
http://quickhost.qbtk.com/download.php?id=238
Player 1:
Code:
W
Shift ASD
Player 2:
Up,down,left,right,Enter
i have a task for any VB coder who wants to try their hand..


if you'll notice, when both player's laser's hit each other, they explode. that explosion was initially meant to kill anyone who touches it. can someone add that bit of code in? there already is a function in there where i tried to code it, but i suck with radius stuff. so can anyone try to add that function's code? and if you do, please dont changhe any other code...
Code:
Function ExploKilled(mPlayer As Integer) As Boolean
    ExploKilled = False
    px = player(mPlayer).mShape.Left
    wdth = player(mPlayer).mShape.Width
    py = player(mPlayer).mShape.Top
    hgt = player(mPlayer).mShape.Height
    
    
    If px + wdth > explosion.Left And px < explosion.Left + explosion.Width Then
        If py + hgt > explosion.Top And px < explosion.Top + explosion.Height Then
            ExploKilled = True
        End If
    End If
    
End Function

Square box mode, to make it circle, you would do something like:
distance = SQR((px-explox)^2 + (py-exploy)^2)

And then check:
If distance < explosion.widht (or height) Then killed

Roughly...
http://quickhost.qbtk.com/download.php?id=239
Tab and Del are the new Mine buttons Wink
im VERY proud of the gfx i did for those Mines

also, can someone actually write out the exact radius code i would need?
I don't know VB... Well, I know Baby VB(QB) and some math, but anyway...

Wouldn't you just use the distance formula for a radial exlosion?
[quote="A Z!re"]
distance = SQR((px-explox)^2 + (py-exploy)^2)
[quote]

I don't know if it matters in VB, but in QB it makes a hella difference in speed, if you do it with mul's only...

Rx=(px-explox)
Ry=(py-exploy)
Dist=Sqr(Rx*Rx+Ry*Ry)

If Dist<= BombRad then
BlowTheShitOutOfTheThing Thing%
End If

Maybe you already know this though... :lol:
I just couldn't think of a better way for it. Wink
the main problem i have is that i made the explosion using
object.Left = object.Left - 1
object.Top = object.Top - 1
object.Width = object.Width + 2
object.Height = object.Height + 2

see? aint even usin any radius...
thanks for both of your helps, it works now. but im waitin for me to impliment more features and pickups before i release another ver.... Wink

anyone EXCITED!?
added AI
watch for any bugs

notice the new powerup item Big Grin

http://quickhost.qbtk.com/download.php?id=241

it seems there IS reward in organization... never would i have thought my code could get so large and so easily manipulated to add a third AI player...
*bump* this is fun, trust me.