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

Username:   Password: 
 RegisterRegister   
 How do I make a boost button for my game also how to do collision with this game?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
CoD




PostPosted: Mon Jun 20, 2011 11:40 am   Post subject: How do I make a boost button for my game also how to do collision with this game?

colorback (white)
var x := 265
var y := 250
const INCREMENT : int := 10
var chars : array char of boolean
var a := 210
var b := 220
var circle1rad : int
var circle2rad :int
var font1,font2,font3,font4,font5 :int
font1 := Font.New("Comicsans:20:bold")
font2 := Font.New("Mono:50:bold")
font3 := Font.New("Mono:50:bold")
font4 := Font.New("Mono:50:bold")
font5 := Font.New("Comicsans:50:bold")
circle1rad := 12
circle2rad := 12




View.Set("graphics:500,500")
cls
Font.Draw("Are You Ready?",150,maxy div 2,font1,black)
delay(500)
cls
Font.Draw("3",220,maxy div 2,font2,black)
delay(500)
cls
Font.Draw("2",220,maxy div 2,font3,black)
delay(500)
cls
Font.Draw("1",220,maxy div 2,font4,black)
delay(500)
cls
Font.Draw("Sumo",177,maxy div 2,font5,black)
delay(500)
cls

loop
View.Update
View.Set("offscreenonly")
View.Set("graphics:500,500")
cls
Draw.FillOval (a + 20, b + 30,circle1rad, circle1rad , black)
Draw.FillOval (x, y,circle2rad,circle2rad, red)
Draw.Oval(250,250,230,250,black)


Input.KeyDown (chars)
if chars (KEY_LEFT_ARROW) and chars (KEY_UP_ARROW) then
x := x - INCREMENT
y := y + INCREMENT
Draw.FillOval (x - 1, y - 1, 5, 5, red)
elsif chars (KEY_RIGHT_ARROW) and chars (KEY_UP_ARROW) then
x := x + INCREMENT
y := y + INCREMENT
Draw.FillOval (x + 2, y + 1, 5, 5, red)
elsif chars (KEY_LEFT_ARROW) and chars (KEY_DOWN_ARROW) then
y := y - INCREMENT
x := x - INCREMENT
Draw.FillOval (x - 1, y - 1, 5, 5, red)
elsif chars (KEY_RIGHT_ARROW) and chars (KEY_DOWN_ARROW) then
y := y - INCREMENT
x := x + INCREMENT
Draw.FillOval (x + 1, y + 1, 5, 5, red)
elsif chars (KEY_LEFT_ARROW) then
x := x - INCREMENT
Draw.FillOval (x - 4, y - 1, 5, 5, red)
elsif chars (KEY_RIGHT_ARROW) then
x := x + INCREMENT
Draw.FillOval (x + 5, y - 1, 5, 5, red)
elsif chars (KEY_UP_ARROW) then
y := y + INCREMENT
Draw.FillOval (x + 1, y + 5, 5, 5, red)
elsif chars (KEY_DOWN_ARROW) then
y := y - INCREMENT
Draw.FillOval (x - 1, y - 5, 5, 5, red)
end if


if chars ('a') and chars ('w') then
a := a - INCREMENT
b := b + INCREMENT
Draw.FillOval (a + 20, b + 30, 5, 5, black)
elsif chars ('a') and chars ('s') then
a := a - INCREMENT
b := b - INCREMENT
Draw.FillOval (a + 21, b + 28, 5, 5, black)
elsif chars ('d') and chars ('w') then
a := a + INCREMENT
b := b + INCREMENT
Draw.FillOval (a + 22, b + 30, 5, 5, black)
elsif chars ('d') and chars ('s') then
a := a + INCREMENT
b := b - INCREMENT
Draw.FillOval (a + 20, b + 29, 5, 5, black)
elsif chars ('a') then
a := a - INCREMENT
Draw.FillOval (a + 15, b + 29, 5, 5, black)
elsif chars ('d') then
a := a + INCREMENT
Draw.FillOval (a + 25, b + 30, 5, 5, black)
elsif chars ('w') then
b := b + INCREMENT
Draw.FillOval (a + 20, b + 36, 5, 5, black)
elsif chars ('s') then
b := b - INCREMENT
Draw.FillOval (a + 20, b + 25, 5, 5, black)
end if
delay (40)
end loop
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Mon Jun 20, 2011 12:00 pm   Post subject: RE:How do I make a boost button for my game also how to do collision with this game?

- what is the problem?
- what did you do to try to solve it?
- use [ code ] tags with _relevant_ code.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Insectoid




PostPosted: Mon Jun 20, 2011 2:00 pm   Post subject: RE:How do I make a boost button for my game also how to do collision with this game?

Here's a big hint: Buttons *are* collisions between some button graphic and the mouse.

There's plenty of tutorials about collision detection, as well as hundreds of responses to other people asking the same question.

Try using the search function at the top of the page.
huskiesgoaler34




PostPosted: Wed Jun 22, 2011 7:08 pm   Post subject: Re: How do I make a boost button for my game also how to do collision with this game?

turing reference guide; search for "button"; it will show u how to make a button
huskiesgoaler34




PostPosted: Wed Jun 22, 2011 7:11 pm   Post subject: Re: How do I make a boost button for my game also how to do collision with this game?

for collision use what dot color

if oval1 is red and oval2 is black then collision = true
Insectoid




PostPosted: Wed Jun 22, 2011 7:13 pm   Post subject: Re: How do I make a boost button for my game also how to do collision with this game?

huskiesgoaler34 @ Wed Jun 22, 2011 7:11 pm wrote:
for collision use what dot color

if oval1 is red and oval2 is black then collision = true


This makes no sense at all. Might as well say "if I am a cow and you are a pig then collision = true".
huskiesgoaler34




PostPosted: Wed Jun 22, 2011 7:28 pm   Post subject: Re: How do I make a boost button for my game also how to do collision with this game?

sorry Embarassed i meant that if the 1 oval is red and 1 oval is black then you can check to see if the color red collides with the color black. this would mean that there was a collision
Insectoid




PostPosted: Wed Jun 22, 2011 8:42 pm   Post subject: RE:How do I make a boost button for my game also how to do collision with this game?

Well, that doesn't explain how to detect if the color red collides with the color black. Might as well say that if one dog is brown and one house is flat then check to see if the chair swallowed a goose.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Wed Jun 22, 2011 8:46 pm   Post subject: Re: How do I make a boost button for my game also how to do collision with this game?

huskiesgoaler34 @ Wed Jun 22, 2011 7:28 pm wrote:
if the 1 oval is red and 1 oval is black then you can check to see if the color red collides with the color black.

Two problems:
- need to check every pixel of one of the circles
- need to know the draw order of both circles
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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  [ 9 Posts ]
Jump to:   


Style:  
Search: