Computer Science Canada [Help] How to make objects move with mouse. |
Author: | razrdude [ Sun Oct 29, 2006 12:14 pm ] | ||
Post subject: | [Help] How to make objects move with mouse. | ||
Hey Im making a shooter game for comp engineering class and i need some help in making this scope movable with the mouse.
Any Help will be appreciated. So this object should move around with the mouse, ive seen this work before but didn't understand the coding behind it. Thanks ![]() |
Author: | Tony [ Sun Oct 29, 2006 12:21 pm ] |
Post subject: | |
First step is to draw it in terms of variables X and Y, instead of your static 55,55 center. This way if I change the variable's value, I'll be able to draw the scope anywhere. Second is to put that all incide a procedure to make everything so much easier. Lastly we grab our mouse position with Mouse.Where and pass values along to the procedure we've made above. |
Author: | razrdude [ Sun Oct 29, 2006 12:25 pm ] |
Post subject: | |
sorry to sound stupid, but i understood the first part, where they become variables, so you assign then to the mouse x, y? can you further explain the second part with the mouse position. idk if theres any other tut for this, if so please guide me |
Author: | richcash [ Sun Oct 29, 2006 1:37 pm ] | ||||
Post subject: | |||||
Well, after you change everything you're drawing to x and y rather than (55, 55), you put it in a procedure.
Then, you make a loop and use the Mouse.Where (x, y, button) command to make the variables x and y the position of the mouse on the screen. Then call the draw procedure you made.
And just remember to make your variables -- x, y and button -- which should be of type int. |
Author: | razrdude [ Sun Oct 29, 2006 1:52 pm ] | ||
Post subject: | |||
umm I tried what you said, and the scope follows the mouse, but it leaves a imprint and is flashing like crazy. Try this and explain?
|
Author: | Ultrahex [ Sun Oct 29, 2006 1:55 pm ] |
Post subject: | |
First Of All, Your Not Clearing the Screen command to clear screen is CLS second of all, there is no second buffer, so it draws each line directly to screen, you need to do a buffer frame, See View.Update and View.Set("offscreenonly") Hopefully that helps (there is tutorials on these in Turing Tutorials) |
Author: | razrdude [ Sun Oct 29, 2006 2:00 pm ] | ||
Post subject: | |||
Really sorry about double posting, but I figured out the trail part, I added a cls but now to get the flickering away I know I need to use View.Set ("offscreenonly") and View.Update but I don't know how to properly incorporate them. Yet again thanks for all the help
|
Author: | Ultrahex [ Sun Oct 29, 2006 2:05 pm ] |
Post subject: | |
Well when you do.. View.Set("offscreenonly") It Makes all the draw commands go to and offscreen buffer. and when you do View.Update it draws the offscreen buffer to the screen. Hopefully you can take this information and figure out the rest ![]() |
Author: | razrdude [ Sun Oct 29, 2006 2:17 pm ] | ||
Post subject: | |||
YESS, I got it, I fixed the lengths of the thin threads and now it seems perfect, Now to make targets of somewhat add a background and get my buttons working. Imma look around Btw heres the latest code
|