Mouse game help
Author |
Message |
R2543
|
Posted: Mon Dec 29, 2008 7:09 pm Post subject: Mouse game help |
|
|
You know those free games on the interent where you have to dodge stuff with your mouse on the screen? well thats what i need to make. Problem is n my code the detection only happens AFTER the program executes, which means if i put any delays in wont detect a collision until the procedure has finished executing.
Turing: | % Declaration Section
var rangeX, rangeY, button : int
var object : int := 1
% Closing walls
proc walls
for x : 0 .. 150
Draw.ThickLine (x, 0, x, 400, 10, 1)
delay (20)
end for
end walls
% Game Screen
proc game
View.Set ("graphics")
title
for x : 0 .. 401
drawline (- 1, - 1 + x, 640, - 1 + x, 66)
end for
loop
mousewhere (rangeX, rangeY, button )
exit when rangeX > 640 or rangeX < 0 or rangeY > 400 or rangeY < 0 or View.WhatDotColour (rangeX, rangeY ) not= 66 or View.WhatDotColour (rangeX + 11, rangeY ) not= 66 or
View.WhatDotColour (rangeX, rangeY - 19) not= 66
if object = 1 then
walls
end if
end loop
title
for x : 0 .. 401
drawline (- 1, - 1 + x, 640, - 1 + x, 40)
end for
end game |
thats the game part of my game. yeah i know i used a whatdotcolour detection but I couldn't think of anything else
I'm quite new to these forums so i dont know much about the tools.
Im supposed to make multiple objects come but i just need to test 1 for now.
Mod Edit: Remember to use syntax tags! Thanks code: | [syntax="turing"]Code Here[/syntax] |
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Amit
|
Posted: Tue Dec 30, 2008 12:59 am Post subject: Re: Mouse game help |
|
|
Maybe you should post the rest of your code, becuase what you've given us doesn't run. It says that the "title" procedure is missing. |
|
|
|
|
 |
Tony

|
Posted: Tue Dec 30, 2008 2:20 am Post subject: RE:Mouse game help |
|
|
if you don't put any delays into procedures (having delays in procedures is usually a sign that something is going wrong), your collision will still not be checked for, until your "walls" procedure finishes it's loop.
Code executes linearly, one step at a time. Think of a better way to organize your main game loop. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
|
|