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

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




PostPosted: 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 Sad
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 Smile
code:
[syntax="turing"]Code Here[/syntax]
Sponsor
Sponsor
Sponsor
sponsor
Amit




PostPosted: 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




PostPosted: 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.
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  [ 3 Posts ]
Jump to:   


Style:  
Search: