Sign in to follow this  
Followers 0
LimeSeed

Slime Volleyball

11 posts in this topic

Here is the starting of my slime volleyball script. It has full collision support, but is a little buggy. Anyone wanna help me a little? So far i have put in the ball, and the slime. the ball bounces realistically off the slime (most of the time :mellow:)

;slime volleyball!
#include "guiconstants.au3"
#include "misc.au3"

Global Const $WS_EX_COMPOSITED = 0x2000000
GUICreate("Slime Volleyball", 700, 250, -1, -1, -1, $WS_EX_COMPOSITED)
$vDll = "user32.dll"
$xp1 = 40
$yp1 = 240
$ballx = 10
$bally = 10
$ballh = True
$ballv = True
$collision = False
$velocity = 0
$g = .7
Global Const $t = 0.017453292519943295 ;pi/180
$p1 = guictrlcreategraphic(0,0,0,0)
guictrlsetgraphic(-1, $GUI_GR_COLOR, 0xFFFFFF, 0xFFFFFF)
guictrlsetgraphic(-1, $GUI_GR_PIE, $xp1, $yp1, 40, 0, 180)
guictrlsetgraphic(-1, $GUI_GR_REFRESH)
guictrlsetgraphic(-1, $GUI_GR_CLOSE)
$ball = guictrlcreategraphic(10,0,0,0)
guictrlsetgraphic(-1, $GUI_GR_COLOR, 0xFFFF00, 0xFFFF00)
guictrlsetgraphic(-1, $GUI_GR_PIE, $ballx, $bally, 10, 0, 360)
guictrlsetgraphic(-1, $GUI_GR_REFRESH)
guictrlsetgraphic(-1, $GUI_GR_CLOSE)
guisetbkcolor(0x0000FF)
guisetstate()

While 1
    if ($bally <= 220) Then
    $g += .1
    EndIf
    sleep(20)
    If(_IsPressed(25, $vDll)) Then $xp1 -=6
    If(_IsPressed(27, $vDll)) Then $xp1 +=6 
    $dx = Abs(($xp1 + 40) - ($ballx + 10))
    $dy = Abs(($yp1) - ($bally + 10))
    $d = Sqrt(($dx * $dx) + ($dy * $dy))
    If(($d < 50) and ($collision = False)) Then
        $dx = Abs(($xp1 + 40) - ($ballx + 10))
        $dy = Abs(($yp1) - ($bally + 10))
        $angle = Atan($dy/$dx)
        $vi = Sqrt(($velocity * $velocity) + ($g * $g))
        $a1 = (findangle($velocity, $g) * $t)
        $vx = $vi * Cos($a1 - $angle)
        $vy = $vi * Sin($a1 - $angle)
        $velocity = $vy
        $g = -1 * ($vx)
        $collision = True
    EndIf
    if($ballx < 0) Then $ballh = True
    if($ballx > 690) then $ballh = False
    if($d > 50) then $collision = False
    guictrlsetpos($p1, $xp1, 0)
    guictrlsetgraphic($p1, $GUI_GR_REFRESH)
    guictrlsetpos($ball, $ballx, $bally)
    $bally += $g
    If($ballh) Then
        $ballx += $velocity
    Else
        $ballx -= $velocity
    EndIf
    $v = false
WEnd

Func findangle($v, $g)
if($v < 0) Then
    $j = 180 + Atan($g/$v)/$t
    if ($ballh = true) then $ballh = True
    if ($ballh = False) then $ballh = False
ElseIf(($v > 0) and ($g >=0)) Then
    $j = atan($g/$v)/$t
    if ($ballh = true) then $ballh = True
    if ($ballh = False) then $ballh = False
ElseIf(($v >0) and ($g < 0)) Then
    $j = 360 + Atan($g/$v)/$t
    $ballh = True
ElseIf(($v = 0) and ($g = 0)) Then
    $j = 0
    msgbox(0, "sf", "sdf")
    $ballh = False
ElseIf(($v = 0) and ($g > 0)) Then
    $j = 90
    $ballh = False
Else
    $j = 270
    $ballh = True
EndIf
    return $j
EndFunc

global $warming = true

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I just tested, you can make the ball go offscreen to the right or left and inside the "slime" at times. Also if you could set the background to a graphic (I created a nice one if you'd like it) and use guictrlsetgraphic(-1, $GUI_GR_COLOR, 0x0EFF00, 0x0EFF00) instead of pure white it looks like a hill is bouncing the sun.

Edit: Low quality version attached below. If you want I can send you the full-quality version.

post-25602-1226466269_thumb.jpg

Edited by dbzfanatic

Share this post


Link to post
Share on other sites

I just tested, you can make the ball go offscreen to the right or left and inside the "slime" at times. Also if you could set the background to a graphic (I created a nice one if you'd like it) and use guictrlsetgraphic(-1, $GUI_GR_COLOR, 0x0EFF00, 0x0EFF00) instead of pure white it looks like a hill is bouncing the sun.

Edit: Low quality version attached below. If you want I can send you the full-quality version.

thats a pretty cool graphic, but i like the background to just be that blue color, im modeling the game after www.oneslime.net

global $warming = true

Share this post


Link to post
Share on other sites

Fair enough,your game after all. What about the bugs with collision? Ideas on why they happen? I have one, perhaps collision isn't checked often enough. That would be my only guess.

Share this post


Link to post
Share on other sites

Fair enough,your game after all. What about the bugs with collision? Ideas on why they happen? I have one, perhaps collision isn't checked often enough. That would be my only guess.

yea im working on collision detection right now :mellow:

global $warming = true

Share this post


Link to post
Share on other sites

Fair enough,your game after all. What about the bugs with collision? Ideas on why they happen? I have one, perhaps collision isn't checked often enough. That would be my only guess.

its not that its not checked enough, its that i messed up with my directions :mellow:

global $warming = true

Share this post


Link to post
Share on other sites

i fixed the collision detection bug, but for the love of god i cannot get it to detect collision of the computer, and i can't make it jump :mellow: any idea how to make it jump?

;slime volleyball!
#include "guiconstants.au3"
#include "misc.au3"

Global Const $WS_EX_COMPOSITED = 0x2000000
GUICreate("Slime Volleyball", 700, 250, -1, -1, -1, $WS_EX_COMPOSITED)
$vDll = "user32.dll"
$xp1 = 40
$yp1 = 240
$xp2 = 500
$yp2 = 240
$ballx = 10
$bally = 10
$ballh = True
$ballv = True
$collision = False
$velocity = 0
$g = 2
$k = 0
$f = 8
$jump = False
Global Const $t = 0.017453292519943295 ;pi/180
$p1 = guictrlcreategraphic(0,0,0,0)
guictrlsetgraphic(-1, $GUI_GR_COLOR, 0x00FF00, 0x00FF00)
guictrlsetgraphic(-1, $GUI_GR_PIE, $xp1, $yp1, 40, 0, 180)
guictrlsetgraphic(-1, $GUI_GR_REFRESH)
guictrlsetgraphic(-1, $GUI_GR_CLOSE)
$p2 = guictrlcreategraphic(0,0,0,0)
guictrlsetgraphic(-1, $GUI_GR_COLOR, 0xFF0000, 0xFF0000)
guictrlsetgraphic(-1, $GUI_GR_PIE, $xp2, $yp2, 40, 0, 180)
guictrlsetgraphic(-1, $GUI_GR_REFRESH)
guictrlsetgraphic(-1, $GUI_GR_CLOSE)
$ball = guictrlcreategraphic(10,0,0,0)
guictrlsetgraphic(-1, $GUI_GR_COLOR, 0xFFFF00, 0xFFFF00)
guictrlsetgraphic(-1, $GUI_GR_PIE, $ballx, $bally, 10, 0, 360)
guictrlsetgraphic(-1, $GUI_GR_REFRESH)
guictrlsetgraphic(-1, $GUI_GR_CLOSE)
$floor = guictrlcreategraphic(0,0,0,0)
guictrlsetgraphic(-1, $GUI_GR_COLOR, 0xCCCCCC, 0xCCCCCC)
guictrlsetgraphic(-1, $GUI_GR_RECT, -1, 240, 700, 10)
guictrlsetgraphic(-1, $GUI_GR_REFRESH)
guictrlsetgraphic(-1, $GUI_GR_CLOSE)
$net = guictrlcreategraphic(0,0,0,0)
guictrlsetgraphic(-1, $GUI_GR_COLOR, 0xFFFFFF, 0xFFFFFF)
guictrlsetgraphic(-1, $GUI_GR_RECT, 340, 220, 5, 40)
guictrlsetgraphic(-1, $GUI_GR_REFRESH)
guictrlsetgraphic(-1, $GUI_GR_CLOSE)
guisetbkcolor(0x0000FF)
guisetstate()
dim $s[2]=[0,0]
$WS_EX_TRANSPARENT = 0x00000020 
$label = guictrlcreatelabel("Slime Volleyball By Isaac. Click here to play!", 200, 100, 500, 70)
guictrlsetbkcolor(-1, $GUI_BKCOLOR_TRANSPARENT)
guictrlsetcolor($label, 0xFFFFFF)
$p1score = guictrlcreatelabel("0", 0, 0, 50, 50)
guictrlsetcolor(-1, 0xFFFFFF)
guictrlsetbkcolor(-1, $GUI_BKCOLOR_TRANSPARENT)
guictrlsetfont($p1score, 20)
$p2score = guictrlcreatelabel("0", 680, 0, 50, 50)
guictrlsetcolor(-1, 0xFFFFFF)
guictrlsetbkcolor(-1, $GUI_BKCOLOR_TRANSPARENT)
guictrlsetfont($p2score, 20)
do
$msg = guigetmsg()
if $msg = -3 then Exit

Until ($msg = $label)
;intro
guictrldelete($label)


While 1
    if ($bally <= 220) Then
    $g += .2
    EndIf
    sleep(20)
    $ismoving = $xp1
    If(_IsPressed(26, $vDll) and ($k > - 70) and $jump = False) Then $jump = True
    If($jump) Then
        if($k >= - 70) Then
            $k -= $f
        else
            $k += 8
            
        EndIf
    EndIf
    If($bally >= 220)Then
        if($ballx > 340) Then
            $s[0] += 1
            ;start at beginning
        Else
            $s[1] += 1
            ;start at beginning
        EndIf
    guictrlsetdata($p1score, $s[0])
    guictrlsetdata($p2score, $s[1])
    EndIf
    If((_IsPressed(25, $vDll)) and ($xp1 > 0)) Then $xp1 -=6
    If((_IsPressed(27, $vDll)) and ($xp1 <= 258)) Then $xp1 +=6 
    $distx = Abs(($xp1 + 40) - ($ballx + 10))
    $disty = Abs(($yp1) - ($bally + 10))
    $dist = Sqrt(($distx * $distx) + ($disty * $disty))
    If(($dist < 50) and ($collision = False)) Then
        $distx = (($xp1 + 40) - ($ballx + 10))
        $disty = (($yp1) - ($bally + 10))
        $angle = Atan($disty/$distx)
        $vi = Sqrt(($velocity * $velocity) + ($g * $g))
        $a1 = (findangle($velocity, $g) * $t)
        $vx = $vi * Cos($a1 - abs($angle))
        $vy = $vi * Sin($a1 - abs($angle))
        If((Abs($ismoving - $xp1) = 6) or (Abs($ismoving - $xp1) = 12)) Then
        $velocity = $vy + 3
        Else
        $velocity = $vy
        EndIf
        $g = -1 * ($vx - 1)
        $collision = True
    Else
        $collision = False
    EndIf

    if($ballx <= 0) Then $velocity *= -1
    if($ballx >= 690) then $velocity *= -1
    if($dist > 50) then $collision = False
    guictrlsetpos($p1, $xp1, $k)
    guictrlsetgraphic($p1, $GUI_GR_REFRESH)
    guictrlsetpos($ball, $ballx, $bally)
    $bally += $g
    If($ballh) Then
        $ballx += $velocity
    Else
        $ballx -= $velocity
    EndIf
    $v = false
WEnd

Func findangle($v, $g)
if($v < 0) Then
    $j = 180 + Atan($g/$v)/$t
ElseIf(($v > 0) and ($g >=0)) Then
    $j = atan($g/$v)/$t
ElseIf(($v >0) and ($g < 0)) Then
    $j = 360 + Atan($g/$v)/$t
ElseIf(($v = 0) and ($g = 0)) Then
    $j = 0
ElseIf(($v = 0) and ($g > 0)) Then
    $j = 90
Else
    $j = 270
EndIf
    if($angle <= 0) Then
    $ballh = true
    Else
    $ballh = False
    EndIf
    return $j
EndFunc

global $warming = true

Share this post


Link to post
Share on other sites

I just woke up (literally 2 minutes ago) so I'm not 100% right now but why not use the same thing to find the jump up/down angle as you use to find the ball's angle as it drops after a bounce? Once it's in the air you should start the check and continue it until it hits a the far left/right side of its field or the "ground" of the game. Also for the clicking I say you should have the ball directly over the starting blob because once the screen is clicked it's a bit of a race to get to the arrow keys. If it's directly above it should be safe for at least one bounce. Also is there a way to reset the game without restarting the app? I haven't gone through thoroughly so I don't know but if there is what is it? If not, why not make one?

Share this post


Link to post
Share on other sites

I like the way your GUI is done along with the angles. While I realise that you are still writing the code and the final code may be neater, it may be easier to code things slightly differently.

- The positions of both slimes should be in an array (you can use a simple loop to handle both slimes [moving the slime, ball movements etc])

- The arrays that contain the slimes should also contain the coordinates of the slime (so the array should look something like $slime[player][coordinate] - where player is 0 or 1 and coordinate is 0 or 1 (where x is 0 and y is 1)

There are a few quick changes which you probably have not got around to yet however would be useful.

- Start with the slime and ball on the left in the centre of that section

- When the ball touches the ground have text with the number of deaths and increment this and start a new game [or code the part for points and look at which side of the net it is].

- Allow anywhere to be clicked when starting a game (rather than only the text displayed)

- Fix the bug where you can't use escape or alt+f4 to close the game once you have started (it may be useful to have this as an option [it might make testing it nicer however you might want to disable this for the completed version.

I originally posted the following under Collision Detector.

You can detect the collision by measuring the distance between the two circles using the coordinates of the centres using

distance=sqrt( (x2-x1)^2 + (y2-y1)^2)

If the distance is equal to (or less than) the sum of the radius of both circles than a collision has occurred.

- In your case one of the objects is a semicircle (so you don't have the bottom of this circle). So if the vertical coordinate of the circle [y1] is less than that of the semicircle [y2] then you should use

distance_x=abs(x2-x1) - in a collision this will be equal to (or less than) the sum of the radii of both circles

distance_y=y2-y1 - in a collision this will be equal to (or less than) the radius of the circle [no need for the absolute value because this method is only used when the conditions are met (the circle is below the semicircle, y1<y2)]

For a collision both the horizontal and vertical conditions must be satisfied (If you are using a coordinate system where the y values get smaller as you go up you need to change the calculations and conditions around [or just swap y1 for y2].

Your current code that you have posted does not appear to handle the part where the ball is below the slime that well. However it can handle when the ball is above the slime (with a few issues)

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

I have started changing your code, currently I have just moved things into arrays and added a bit of documentation to these parts.

I have fixed jumping (one of the problems with the way you had coded jumping before was that you set a variable to presumably say to jump up and once the slime got to this height you made it go down, next loop it would be below the threshold and go up and just repeat. Once the slime gets to the top the code needed to set your variable for jumping up to 0.

Another problem was that your "collision detection" did not realise that the coordinates of the slime had changed once it had jumped (perhaps you were going to code this after you got jumping working)).

- it now starts a new game after the ball hits the ground.

- There are some issues with the interaction between the slime and the ball where the ball does not properly bounce of the slime

- I have given it a forum release version because I intend on editing this post a few times.

#include <guiconstants.au3>
#include <misc.au3>
$vDll = "user32.dll"

#cs
;slime volleyball!
;http://www.autoitscript.com/forum/index.php?showtopic=84253&hl=slime

forum release v1.0.6

Future features:
- Add a key to start again
- interaction with net
- is moving appears to be old position (if this is the case it should be renamed)
- user timer to work out how long to sleep (delay-time_spent_in_loop)
- move gui options into a function gui_defaults
- fix handling of area below slime  (with collisions / distance formula)
- replay game
#ce

;______________________________________________________
const $GROUND_HEIGHT=240
;dim $collision  ; what does this variable do?
dim $velocity

;___________ BALL _____________________________
dim $ball[3]    ; image reference/ x / y
;$ball[1]=154
;$ball[2]=200

$ball_radius=10
dim $ballh

; _____________ SLIME _________________________
dim $slime[2][4] ; player, image_reference / x / y / jump  - the default values are  set in the function start_game -  [jump indicates that the slime is moving up] 
dim $slime_visual[2][2] ; player,  radius / colour

for $i=0 to 1
    $slime_visual[$i][0]=40 ; radius
next

;-------- colour --------------
$slime_visual[0][1]=0x00FF00
$slime_visual[1][1]=0xFF0000
;--------------------------------------
$slime_jump_height=70
$slime_jump_up_speed=10
$slime_jump_down_speed=8

;_____________________________________

const $NET_THICKNESS=5

global $ball_y_movement ; this used to be called g

;$k = 0
;$f = 8
;$jump = False
Global Const $t = 0.017453292519943295 ;pi/180

;______________________________ GUI ___________________________________________
Global Const $WS_EX_COMPOSITED = 0x2000000
GUICreate("Slime Volleyball", 700, 250, -1, -1, -1, $WS_EX_COMPOSITED)
;---------- Slime -----------------------
for $i=0 to 1
    $slime[$i][0]=guictrlcreategraphic(0,0,0,0)
    guictrlsetgraphic(-1, $GUI_GR_COLOR, $slime_visual[$i][1], $slime_visual[$i][1])
    guictrlsetgraphic(-1, $GUI_GR_PIE, 0, $GROUND_HEIGHT, $slime_visual[$i][0], 0, 180) ; the position of the slimes is relative to the start position
    guictrlsetgraphic(-1, $GUI_GR_REFRESH)
    guictrlsetgraphic(-1, $GUI_GR_CLOSE)
    guictrlsetpos($slime[$i][0], $slime[$i][1], $slime[$i][2])
next
;--------- Ball ---------------------------
$ball[0] = guictrlcreategraphic(10,0,0,0)
guictrlsetgraphic(-1, $GUI_GR_COLOR, 0xFFFF00, 0xFFFF00)
guictrlsetgraphic(-1, $GUI_GR_PIE, 0, $GROUND_HEIGHT, 10, 0, 360)
guictrlsetgraphic(-1, $GUI_GR_REFRESH)
guictrlsetgraphic(-1, $GUI_GR_CLOSE)
guictrlsetpos($ball[0], $ball[1], -$ball[2])
;-------------------------------------
$floor = guictrlcreategraphic(0,0,0,0)
guictrlsetgraphic(-1, $GUI_GR_COLOR, 0xCCCCCC, 0xCCCCCC)
guictrlsetgraphic(-1, $GUI_GR_RECT, -1, $GROUND_HEIGHT, 700, 10)
guictrlsetgraphic(-1, $GUI_GR_REFRESH)
guictrlsetgraphic(-1, $GUI_GR_CLOSE)
;---------------------------
$net = guictrlcreategraphic(0,0,0,0)
guictrlsetgraphic(-1, $GUI_GR_COLOR, 0xFFFFFF, 0xFFFFFF)
guictrlsetgraphic(-1, $GUI_GR_RECT, 340, 220, $NET_THICKNESS, 40)
guictrlsetgraphic(-1, $GUI_GR_REFRESH)
guictrlsetgraphic(-1, $GUI_GR_CLOSE)
guisetbkcolor(0x0000FF)
guisetstate()

;______________________________________________________________
dim $s[2]=[0,0]
$WS_EX_TRANSPARENT = 0x00000020
$label = guictrlcreatelabel("Slime Volleyball By Isaac and Adam1213. Click here to play!", 200, 100, 500, 70)
guictrlsetbkcolor(-1, $GUI_BKCOLOR_TRANSPARENT)
guictrlsetcolor($label, 0xFFFFFF)
$p1score = guictrlcreatelabel("0", 0, 0, 50, 50)
guictrlsetcolor(-1, 0xFFFFFF)
guictrlsetbkcolor(-1, $GUI_BKCOLOR_TRANSPARENT)
guictrlsetfont($p1score, 20)
$p2score = guictrlcreatelabel("0", 670, 0, 50, 50) ; 680
guictrlsetcolor(-1, 0xFFFFFF)
guictrlsetbkcolor(-1, $GUI_BKCOLOR_TRANSPARENT)
guictrlsetfont($p2score, 20)

start_game()

;__________________________________________
do
    $msg = guigetmsg()
    if $msg = -3 then Exit
Until $msg = $label

guictrldelete($label)

;______________________________________________________________________
While 1
    $msg = guigetmsg()
    if $msg = -3 then Exit
    
    if ($ball[2] <= 220) Then
        $ball_y_movement -= .2
    EndIf
    sleep(20)
    $ismoving = $slime[0][1] ; what does this do?
    
    ; ___________ JUMP __________________________
    If _IsPressed(26, $vDll) AND $slime[0][2]=0 Then ; make sure that the slime is on the ground
        $slime[0][3]=1
    endif
    if $slime[0][3] then ; jump up 
        $slime[0][2]+=$slime_jump_up_speed
        if $slime[0][2]>=$slime_jump_height then 
            $slime[0][3]=0 ; set jump up to 0
        endif
    else
        if $slime[0][2]>0 then ; slime is off the ground
            $slime[0][2]-=$slime_jump_down_speed
            if $slime[0][2]<0 then
                $slime[0][2]=0
            endif
        endif
    endif
    
    ;_____________ BALL _______________________________________ 
    ;------------ check if the ball has hit the ground -----------
    if $ball[2] < $ball_radius then ; the ball must have hit the ground
        if($ball[1] > 340) Then
            $winning_player=0
        Else
            $winning_player=1
        EndIf
        $s[$winning_player] += 1
        guictrlsetdata($p1score, $s[0]) ; change this to an array !!!
        guictrlsetdata($p2score, $s[1])
        sleep(1000)
        start_game()
    EndIf
    ;____________ SLIME MOVEMENT __________________________________
    If (_IsPressed(25, $vDll)) and ($slime[0][1] > $slime_visual[0][0]) Then ; $slime_visual[0][0] is the radius
        $slime[0][1] -=6
    endif
    If ((_IsPressed(27, $vDll)) and ($slime[0][1] <= 340-$slime_visual[0][0]-$NET_THICKNESS)) Then  ; 258
        $slime[0][1] +=6
    endif
    ;___________________________________________________________
    
    $distx = Abs($slime[0][1] - $ball[1])
    $disty = Abs($slime[0][2] - $ball[2])
    $dist = Sqrt(($distx * $distx) + ($disty * $disty))
    
    If $dist <= 50 Then ;If(($dist < 50) and ($collision = False)) Then ; 50 = radius of slime + ball [40 +10]
        $distx = (($slime[0][1]) - ($ball[1]))
        $disty = (($slime[0][2]) - ($ball[2]))
        $angle = Atan($disty/$distx)
        
        if($angle <= 0) Then
            $ballh = true
        Else
            $ballh = False
        EndIf
    
        $vi = Sqrt(($velocity * $velocity) + ($ball_y_movement* $ball_y_movement))
        $a1 = (findangle($velocity, $ball_y_movement) * $t)
        $vx = $vi * Cos(abs($angle)-$a1)
        $vy = $vi * Sin(abs($angle)-$a1)
        If((Abs($ismoving - $slime[0][1]) = 6) or (Abs($ismoving - $slime[0][1]) = 12)) Then
            $velocity = $vy + 3
        Else
            $velocity = $vy
        EndIf
        $ball_y_movement = 1 * ($vx - 1)
        ;$collision = True
    ;Else
        ;$collision = False
    EndIf
    
    ;if $dist > 50 then 
    ;   $collision = False
    ;endif
    
    ; _________ BOUNCE OFF WALLS (still need to add net!!!) __________
    if $ball[1] <= $ball_radius Then
        $velocity *= -1 ; Assuming that the ball must have been moving left to reach the left wall make it move the other way
    endif
    if $ball[1] >= 700-$ball_radius then 
        $velocity *= -1
    endif
    ;_____________________________________________________
    
    $ball[2] += $ball_y_movement
    
    If ($ballh) Then
        $ball[1] += $velocity
    Else
        $ball[1] -= $velocity
    EndIf
    $v = false
    
    guictrlsetpos($slime[0][0], $slime[0][1], -$slime[0][2])
    guictrlsetgraphic($slime[0][0], $GUI_GR_REFRESH)
    
    guictrlsetpos($ball[0], $ball[1], -$ball[2])

    
    tooltip($slime[0][1]&'x'&$slime[0][2]&@CRLF& _
    round($ball[1])&'x'&round($ball[2]),500,0)  
WEnd

Func findangle($v, $ball_y_movement)
    $includedside=Atan($ball_y_movement/$v)/$t
    select
        case $v = 0 and $ball_y_movement = 0
            $j = 0
        case $v = 0 and $ball_y_movement<0
            $j = 90
            
        case $v < 0
            $j = 180 + $includedside
            
        case $v > 0 and $ball_y_movement>=0
            $j = $includedside
            
        case $v > 0 and $ball_y_movement>0
            $j = 360 + $includedside

        case else 
            $j = 270
    endselect
    ;msgbox(0,'','Ball y movement: '&$ball_y_movement&@CRLF& _
    ;'v '&$v&@CRLF& _
    ;'included side '&$includedside&@CRLF& _
    ;'j '&$j)
    return $j
EndFunc

;_______________ START GAME _____________________________

func start_game()
    $ball[1]=154
    $ball[2]=200
    
    $ballh = 1
    $ball_y_movement =- 2
    ;$collision = False
    $velocity = 0
    
    ;------ slime --------  
    $slime[0][1]=154    ;  x coordinate - make sure that the x coordinate + radius of slime is a multiple of the movement multiplier (or the slime won't go all the way to one of the sides)
    $slime[1][1]=500

    for $i=0 to 1
        $slime[$i][2]=0 ; y coordinate
        $slime[$i][3]=0 ; jump up
        guictrlsetpos($slime[$i][0], $slime[$i][1], -$slime[$i][2])
    next
    
    guictrlsetpos($ball[0], $ball[1], -$ball[2])
    guictrlsetgraphic($slime[0][0], $GUI_GR_REFRESH) ; refresh the graphics
endfunc
Edited by Adam1213

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0