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

Username:   Password: 
 RegisterRegister   
 Saving mouse coordinates
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
mynameisbob




PostPosted: 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.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Tue Jul 13, 2004 12:45 am   Post subject: (No 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
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
mynameisbob




PostPosted: Tue Jul 13, 2004 6:21 pm   Post subject: (No 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
the_short1




PostPosted: Fri Jul 16, 2004 11:07 am   Post subject: (No subject)

u know..


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


instead of that..
you can do this..


colorback (black)
cls

works better Smile
DanShadow




PostPosted: Mon Jul 26, 2004 7:01 pm   Post subject: (No 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.
Delta




PostPosted: Thu Aug 05, 2004 11:54 am   Post subject: (No 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...
DanShadow




PostPosted: Thu Aug 05, 2004 3:37 pm   Post subject: (No 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.
Delta




PostPosted: Fri Aug 06, 2004 1:55 am   Post subject: (No 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...
Sponsor
Sponsor
Sponsor
sponsor
DanShadow




PostPosted: Sat Aug 07, 2004 2:29 pm   Post subject: (No 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]
AsianSensation




PostPosted: Sat Aug 07, 2004 5:49 pm   Post subject: (No 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?
DanShadow




PostPosted: Sun Aug 08, 2004 6:19 pm   Post subject: (No subject)

Yep, I was recently added to the Turing Gods club. Very Happy Your still special AsianSensation.
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  [ 11 Posts ]
Jump to:   


Style:  
Search: