Computer Science Canada

Saving mouse coordinates

Author:  mynameisbob [ Mon Jul 12, 2004 10:08 pm ]
Post subject:  Saving mouse coordinates

ok heres what i want the program to do...

code:
var xm, ym, b : int
setscreen ("offscreenonly")
drawfillbox (0, 0, maxx, maxy, black)
drawfilloval (200, 200, 100, 100, brightblue)
loop
    mousewhere (xm, ym, b)
    if b = 1 and whatdotcolour (xm, ym) = brightblue then
        drawfilloval (xm, ym, 10, 10, black)
    end if
    delay (10)
    View.Update
end loop


but i want to place these two lines inside the loop
Quote:
drawfillbox (0, 0, maxx, maxy, black)
drawfilloval (200, 200, 100, 100, brightblue)


and whenever the user clicks the mouse on the blue circle i want to save the coordinates where they clicked and draw the black circle at that point each time you go through the loop.

Author:  Tony [ Tue Jul 13, 2004 12:45 am ]
Post subject: 

so have an array, and each time you're about to draw your black circle, record its position in the array.

then when you need to draw those circles on screen, just use a forloop to go though the array's index

Author:  mynameisbob [ Tue Jul 13, 2004 6:21 pm ]
Post subject: 

yea, the first time i used an array it didnt work out, but now i've got it. the problem was, everytime i click, the same values were being assigned to all the variables in the array. i changed a few lines around and now got it to work. thanks

Author:  the_short1 [ Fri Jul 16, 2004 11:07 am ]
Post subject: 

u know..


drawfillbox (0, 0, maxx, maxy, black)


instead of that..
you can do this..


colorback (black)
cls

works better Smile

Author:  DanShadow [ Mon Jul 26, 2004 7:01 pm ]
Post subject: 

or you could try this:
code:

type bullets:
record
x,y:int
end record
var bullet:array 1.. 9999 of bullets
var bulletsShot,x,y,b:int:=1
%Set initial bullets offset off the screen, to make the for loop
%  that draws the bullets work correctly.
bullet(bulletsShot).x:=-50
bullet(bulletsShot).y:=-50
loop
setscreen("offscreenonly")
View.Update
cls
mousewhere(x,y,b)
delay(5)
for i:1..bulletsShot
drawfilloval(bullet(i).x,bullet(i).y,1,1,16)
end for
if b=1 then
bullet(bulletsShot).x:=x
bullet(bulletsShot).y:=y
bulletsShot+=1
end if
end loop

I dont have Turing on this computer, but this code should work pretty well. I included it on my friends shooting gallery ISU, he got a pretty good mark just for including that in it. So that might work for you.

Author:  Delta [ Thu Aug 05, 2004 11:54 am ]
Post subject: 

your code doesn't work... jeez... I know I'm posting late... but I don't care... because all your (DanShadow's) posts are like 10 days after the last response... your pretty much spamming old topics just to increase your post count and look all fancy... typical computer geek... get a life dude...

Author:  DanShadow [ Thu Aug 05, 2004 3:37 pm ]
Post subject: 

Hey Delta, be quiet. This post was made like many months ago fool. And that was before I was even a mod...so just keep your comments to yourself.

Author:  Delta [ Fri Aug 06, 2004 1:55 am ]
Post subject: 

Don't even try tellin' me what to do... and I did say that my post was late... which goes to show that you don't pay much attention to detail in the first place... like how I have more seniority than you do since I joined compsci first and all anyways... have a nice day...

Author:  DanShadow [ Sat Aug 07, 2004 2:29 pm ]
Post subject: 

Makes no difference, and I DID read that. But you seriously are like flaming me alot recently, so, plz stop the burning. And since this post has
already been answer:
[LOCKED]

Author:  AsianSensation [ Sat Aug 07, 2004 5:49 pm ]
Post subject: 

What? I didn't know DanShadow could lock stuff in Turing section, I feel so un-unique now... Crying or Very sad Crying or Very sad

anyways guys, don't kill each other, what would we do if we are suddenly missing two mods once the two of you decide to double K.O. each other?

Author:  DanShadow [ Sun Aug 08, 2004 6:19 pm ]
Post subject: 

Yep, I was recently added to the Turing Gods club. Very Happy Your still special AsianSensation.


: