Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 game
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
r3beL




PostPosted: Wed Jun 22, 2005 5:14 pm   Post subject: game

need help with my slime volleyball game. can't get ball to hit the slime.
Sponsor
Sponsor
Sponsor
sponsor
vagyb




PostPosted: Wed Jun 22, 2005 5:18 pm   Post subject: (No subject)

let me the first one to say that posting the code would be nice
r3beL




PostPosted: Wed Jun 22, 2005 5:26 pm   Post subject: (No subject)

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) <= 1 then
x_1 := 2
elsif (bally - size) = 1 then
y_1 := 2
elsif (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) <= slime1x and (bally - size) <= slime1y then
x_1 := x_1 * 1
y_1 := y_1 * -1
end if
ballx := ballx + x_1
bally := bally + y_1
end ball

procedure points1
if bally = 51 and ballx >= 398 and ballx <= 720 then
pt1 := pt1 + 1
if pt1 = 1 then
Draw.FillOval (25, 515, 20, 20, colours1)
elsif pt1 = 2 then
Draw.FillOval (70, 515, 20, 20, colours1)
elsif pt1 = 3 then
Draw.FillOval (115, 515, 20, 20, colours1)
elsif pt1 = 4 then
Draw.FillOval (160, 515, 20, 20, colours1)
elsif pt1 = 5 then
Draw.FillOval (205, 515, 20, 20, colours1)
elsif pt1 = 6 then
Draw.FillOval (250, 515, 20, 20, colours1)
end if
end if
end points1

procedure points2
if bally = 51 and ballx >= 5 and ballx <= 398 then
Draw.FillOval (755, 515, 20, 20, colours2)
View.Update
end if
end points2

procedure scores
Draw.Oval (755, 515, 20, 20, colours2)
Draw.Oval (710, 515, 20, 20, colours2)
Draw.Oval (665, 515, 20, 20, colours2)
Draw.Oval (620, 515, 20, 20, colours2)
Draw.Oval (575, 515, 20, 20, colours2)
Draw.Oval (530, 515, 20, 20, colours2)
Draw.Oval (25, 515, 20, 20, colours1)
Draw.Oval (70, 515, 20, 20, colours1)
Draw.Oval (115, 515, 20, 20, colours1)
Draw.Oval (160, 515, 20, 20, colours1)
Draw.Oval (205, 515, 20, 20, colours1)
Draw.Oval (250, 515, 20, 20, colours1)
end scores

Pic.Draw (title, 125, 50, picCopy)

loop
if Input.hasch then
Input.KeyDown (input)
if input ('1') then
cls
exit
end if
if input ('2') then
cls
Draw.FillBox (0, 0, maxx, maxy, black)
Pic.Draw (control1, -10, 200, picMerge)
Pic.Draw (control2, 275, -25, picMerge)
Font.Draw ("PRESS 'R' TO RETURN", 50, 30, font1, 76)
elsif input ('r') then
cls
Pic.Draw (title, 125, 50, picCopy)
end if
View.Update
end if
end loop

loop
put "what is player one's name? (max 10 characters)"
get name1 : *
put "What is player two's name? (max 10 characters)"
get name2 : *
exit
end loop

setscreen ("offscreenonly")

loop
if slime1x >= 328 then
slime1x := 328
elsif slime1x <= 61 then
slime1x := 61
end if
if slime2x <= 460 then
slime2x := 460
elsif slime2x >= 726 then
slime2x := 726
end if
if slime1y > 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




PostPosted: Wed Jun 22, 2005 5:34 pm   Post subject: (No subject)

okay also use
code:
commands and please post the pictures zipped up so the program runs.
r3beL




PostPosted: Wed Jun 22, 2005 5:44 pm   Post subject: (No subject)

ok


game.zip
 Description:

Download
 Filename:  game.zip
 Filesize:  172.8 KB
 Downloaded:  159 Time(s)

vagyb




PostPosted: Wed Jun 22, 2005 5:52 pm   Post subject: (No subject)

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




PostPosted: Wed Jun 22, 2005 5:53 pm   Post subject: (No subject)

thanx
r3beL




PostPosted: Wed Jun 22, 2005 6:41 pm   Post subject: (No subject)

still having trouble to get ball to hit slime.
Sponsor
Sponsor
Sponsor
sponsor
vagyb




PostPosted: Wed Jun 22, 2005 7:33 pm   Post subject: (No subject)

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




PostPosted: Thu Jun 23, 2005 11:31 am   Post subject: (No subject)

Please use [code] tags when posting code, both of you.
Also, check out the Tutorials on Circular Collision Detection.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 10 Posts ]
Jump to:   


Style:  
Search: