
-----------------------------------
r3beL
Wed Jun 22, 2005 5:14 pm

game
-----------------------------------
need help with my slime volleyball game. can't get ball to hit the slime.

-----------------------------------
vagyb
Wed Jun 22, 2005 5:18 pm


-----------------------------------
let me the first one to say that posting the code would be nice

-----------------------------------
r3beL
Wed Jun 22, 2005 5:26 pm


-----------------------------------
ok

setscreen ("graphics:max;max,nobuttonbar")

var input : array char of boolean
var pt1, pt2 : int := 0
var ballx : int
var bally : int
var size : int := 10
var x_1, y_1 : int := 1
var slime1x := 200
var slime1y := 51
var slime2x := 600
var slime2y := 51
var colours1 : int := 12
var colours2 : int := 31
var title : int := Pic.FileNew ("slime.bmp")
var control1 : int := Pic.FileNew ("control1.bmp")
var control2 : int := Pic.FileNew ("control2.bmp")
var name1, name2 : string (10)
var font1, font2 : int
x_1 := 2
y_1 := 2
font1 := Font.New ("Comic Sans MS:18:bold")
font2 := Font.New ("Comic Sans MS:30:bold")
randomize
randint (ballx, size, maxx - size)
randint (bally, size, maxy - size)

procedure background
    Draw.FillBox (0, 0, maxx, maxy, blue)
    Draw.FillBox (0, 0, maxx, 50, darkgrey)
    Draw.FillBox (390, 100, 398, 50, white)
end background

procedure slimes
    Draw.FillArc (slime1x, slime1y, 60, 60, 0, 180, colours1)
    Draw.FillArc (slime2x, slime2y, 60, 60, 0, 180, colours2)
    if Input.hasch then
        Input.KeyDown (input)
        if input (KEY_UP_ARROW) then
            slime2y := slime2y + 150
        end if
        if input ('w') then
            slime1y := slime1y + 150
        end if
        if input (KEY_RIGHT_ARROW) then
            slime2x := slime2x + 20
        end if
        if input ('d') then
            slime1x := slime1x + 20
        end if
        if input (KEY_LEFT_ARROW) then
            slime2x := slime2x - 20
        end if
        if input ('a') then
            slime1x := slime1x - 20
        end if
        if input ('s') then
            colours1 := Rand.Int (35, 53)
        end if
        if input (KEY_DOWN_ARROW) then
            colours2 := Rand.Int (10, 20)
        end if
    end if
end slimes

procedure ball
    drawfilloval (ballx, bally, size, size, yellow)
    if (ballx - size) = (785 - 1) then
        x_1 := x_1 * -1
    elsif (bally + size) >= (300 - 1) then
        y_1 := y_1 * -1
    end if
    if (ballx - size) >= slime1x and (ballx + size) = 328 then
        slime1x := 328
    elsif slime1x  51 then
        slime1y := slime1y - 3
    end if
    if slime2y > 51 then
        slime2y := slime2y - 3
    end if
    points2
    background
    scores
    slimes
    ball
    Font.Draw (name1, 10, 475, font1, colours1)
    Font.Draw (name2, 515, 475, font1, colours2)
    Font.Draw ("V.", 350, 500, font2, colours1)
    Font.Draw ("S.", 400, 500, font2, colours2)
    View.Update
    exit when pt1 = 6 or pt2 = 6
end loop

-----------------------------------
vagyb
Wed Jun 22, 2005 5:34 pm


-----------------------------------
okay also use  commands and please post the pictures zipped up so the program runs.

-----------------------------------
r3beL
Wed Jun 22, 2005 5:44 pm


-----------------------------------
ok

-----------------------------------
vagyb
Wed Jun 22, 2005 5:52 pm


-----------------------------------
okay first thing you should do is make the second player be able to move full screen lenght, second make sure when u press up key over and over for the slime to not go up forever.

for the detection, best bet is to do whatdotcolor, make the ball yellow for example and whenever any part of the ball touches red or white (the slimes) then make it go the direction u want (i'm not too good with the bouncing off at degrees part). but ya thats main idea.

-----------------------------------
r3beL
Wed Jun 22, 2005 5:53 pm


-----------------------------------
thanx

-----------------------------------
r3beL
Wed Jun 22, 2005 6:41 pm


-----------------------------------
still having trouble to get ball to hit slime.

-----------------------------------
vagyb
Wed Jun 22, 2005 7:33 pm


-----------------------------------
okay try
var ballx : int
var bally : int 


if whatdotcolor (ballx , bally ) = black %if u make the slime black
or whatdotcolor (ballx + 2 , bally + 2) = black
or whatdotcolor (ballx + 4 , bally + 4) = black
or whatdotcolor (ballx + 6 , bally + 6) = black
or whatdotcolor (ballx + 8 , bally + 8) = black
then 
%put w/e u want to happen here)

if u want change the ballx and bally + coordiantes to fit ur needs, just giving an example, its good to import the picture from a file into turing and also create a picture width and height

var ball : int
var ballHeight: int
var ballWidth : int
ball := Pic.FileNew ("ball.bmp") %save the ball in the same folder as .bmp
ballWidth := Pic.Width (ball)
ballHeight := Pic.Height (ball)

this way when u do whatdotcolor coordinates u can use ballwidth and height to make ur job easier.

-----------------------------------
Delos
Thu Jun 23, 2005 11:31 am


-----------------------------------
Please use [code] tags when posting code, both of you.
Also, check out the Tutorials on Circular Collision Detection.
