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

Username:   Password: 
 RegisterRegister   
 Help with Mouse.Where
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
D_homes




PostPosted: Sat Nov 07, 2009 10:31 pm   Post subject: Help with Mouse.Where

Hey guys, I only have about two months experience with Turing (I'm in grade 10 taking ISC) so go easy on me.
I am trying to make a game where enemies are moving from the left side of the screen, the goal is to eliminate them before they reach the right side. The user clicks on the enemy to kill it. I understand how to program the rest of the game but I'm running into some serious problems with Mouse.Where. A simple delay and cls could solve this problem but it doesn't work with the off screen buffer which i used to eliminate the flashing.

Don't tell me to go and read the mousewhere tutorials ... I've already read them and they didn't help me at all with the goal i was trying to obtain with my game.

How could i make it so that after a certain amount of time, the picture is removed. This is because if you click somewhere, the bullet appears there, but if you don't click somewhere else, the picture remains there.

Turing:

View.Set ("graphics, offscreenonly")
var x, y, b : int
var bullet : int

ammo := 120
x := maxx div 2
y := maxy div 2
b := 0
var bulletx, bullety : int := 200
bullet := Pic.FileNew ("bullet_171.gif")


loop

    Mouse.Where (x, y, b)
    if b = 1 and y > bullety then
        bullety := bullety + 2
    end if
    if b = 1 and y < bullety then
        bullety := bullety - 2
    end if
    if b = 1 and x > bulletx then
        bulletx := bulletx + 2
    end if
    if b = 1 and x < bulletx then
        bulletx := bulletx - 2
    end if
    Pic.Draw (bullet, bulletx, bullety, b)
    View.Update
    cls
end loop



Also, how would i implement an ammo system, i tried it, and failed. I tried it as part of the loop, but the number decreases way to fast and if i put in a delay, the bullet moves way to slow.For some messed up reason, it also messed up the Mouse.Where by making the user having to click multiple times to move the bullet where he/she wants it. Would it be best to use the ammo as a procedure on its own?
Sponsor
Sponsor
Sponsor
sponsor
Superskull85




PostPosted: Sat Nov 07, 2009 11:22 pm   Post subject: Re: Help with Mouse.Where

Based on the code you posted, the bullet moves towards where the mouse currently at, and it only moves when the mouse it is clicked. Is this an intended behavior?

If it is than you could use a boolean variable to determine if the bullet should be drawn or not. Initially the boolean variable would be set to false, and when the mouse is clicked you would set this variable to true. If the bullet hit an enemy than you would set the boolean variable to false.

Turing:
...
var drawbullet : boolean := false %If this variable is set to true than the bullet will be drawn, otherwise it won't

loop

    Mouse.Where (x, y, b)
    if b = 1 and y > bullety then
        bullety := bullety + 2
        %Set drawbullet to true
    end if
    ...
    if drawbullet then %If the bullet should be drawn
        Pic.Draw (bullet, bulletx, bullety, b)
    end if
    if bullet_hit_enemy then
        %Set drawbullet to false
    end if
    ...
end loop

However, what I think you really want to do is have the bullet travel to where the mouse was clicked even when the mouse is not clicked. Is this what you want instead?
D_homes




PostPosted: Sat Nov 07, 2009 11:32 pm   Post subject: RE:Help with Mouse.Where

I want the bullet to travel where the mouse is clicked, but i want the bullet to disappear after a certain amount of time if the user does not click again
D_homes




PostPosted: Sun Nov 08, 2009 10:39 am   Post subject: RE:Help with Mouse.Where

never mind, i figured it out. Thanks for your help!
Turing_Gamer




PostPosted: Thu Nov 19, 2009 9:41 pm   Post subject: Re: Help with Mouse.Where

Quick question...
How did you post the Turing code like that?
D_homes




PostPosted: Thu Nov 19, 2009 9:44 pm   Post subject: Re: Help with Mouse.Where

Turing_Gamer @ Thu Nov 19, 2009 9:41 pm wrote:
Quick question...
How did you post the Turing code like that?


use the tags

code:

[code] at the beginning of the code.


And [/code] at the end of it.
Zren




PostPosted: Thu Nov 19, 2009 9:45 pm   Post subject: Re: Help with Mouse.Where

code:
[syntax="turing"][/syntax]


Turing:

#turing colours
put "Are Awesome"


Shucksdangnabit
D_homes




PostPosted: Thu Nov 19, 2009 9:55 pm   Post subject: Re: Help with Mouse.Where

Zren @ Thu Nov 19, 2009 9:45 pm wrote:
code:
[syntax="turing"][/syntax]


Shucksdangnabit


Whenever i try that it doesn't work so i just use [code].
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Nov 19, 2009 10:00 pm   Post subject: RE:Help with Mouse.Where

Just because you can't get it to work for yourself, while it clearly works for others, perhaps you shouldn't be telling new members to not use an available feature.

Also, try to use it now, in a reply. I want to see in which way it doesn't work.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Turing_Gamer




PostPosted: Sun Nov 22, 2009 4:55 pm   Post subject: Re: Help with Mouse.Where

Turing:

%Testing...

Alright thanks...
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: