Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / object moving by mouse

Author
Message
4N!ALA70R
19
Years of Service
User Offline
Joined: 22nd Jan 2005
Location: Perth, Western Oz
Posted: 14th Feb 2005 17:53 Edited at: 14th Feb 2005 18:09
i am trying to use my mouse to move an object

here is the code:


for most people you will hav to change the house object to a cube to view it. And as you can see it is like a strategy set up. i am experiencing problems with the object continuously cloning itself, it doesnt go ghost and it does not, most importantly, follow the mouse around the screen.

i figured there is a lot of math involved

there is the house attached 37kb

Attachments

Login to view attachments
Rye
21
Years of Service
User Offline
Joined: 30th May 2003
Location: United Kingdom, Blackrod
Posted: 14th Feb 2005 19:11
i think this should work. from what i can tell i think you tried to used this:

if keystate(35)=1 then keystate(35)=0

to stop the clone object command looping. the problem is when the code loops it checks again to see if the key is pressed and if so clone the object. the problem is that in the time it takes you to press a key and then take your finger off it, the program will have looped several times.

by using the flag it will stop this happening.

i have'nt tested it but it should work



4N!ALA70R
19
Years of Service
User Offline
Joined: 22nd Jan 2005
Location: Perth, Western Oz
Posted: 14th Feb 2005 19:43
thankyou rye for that code it solves the problem of cloning the house but it does not let me move the just built house around, so basically i want the house to move around with the mouse and when i click the mouse it stays there until its destroyed.

thankyou again
Rye
21
Years of Service
User Offline
Joined: 30th May 2003
Location: United Kingdom, Blackrod
Posted: 14th Feb 2005 19:52 Edited at: 14th Feb 2005 19:55
ahhh found it
try printing this command to the screen
mousemovex()

you should see that it can go up to about 50 depending on how fast you move your mouse.

youtr line says
if mousemovex()=1 then move object houseno,cx+mousemovex()

and when u move the mouse mousemovex() will be above 1.

try

if mousemovex()>0 then move object houseno,cx+mousemovex()

im at uni at the moment so i cant test any of the code. sorry

edit:

damnit. i forgot. i think there is a problem calling mousemove commands more than once per loop. the best fix for this is to set a variable equal to the mousemovex() at the start of your loop then use the variable instead of mousemovex(). do the same for y (and z if u need it).
4N!ALA70R
19
Years of Service
User Offline
Joined: 22nd Jan 2005
Location: Perth, Western Oz
Posted: 14th Feb 2005 20:03 Edited at: 14th Feb 2005 21:05
well , umm how am i going to say this, it has solved a bug from the code u gave me that it creates and object at the press and the release of 'H' (keystate(35)) but now there are objects being placed like x+2500 (i hav no idea how that happened, but truthfully i think that was there before you helped me), and yeh, you still cant move it, lol

and hey i am only one year off from being able to enter uni (yr12), so today is my lucky day of having a shortage of homework lol

and thanks again
4N!ALA70R
19
Years of Service
User Offline
Joined: 22nd Jan 2005
Location: Perth, Western Oz
Posted: 14th Feb 2005 21:11
to anyone else that wants to help me the code has become a little more complicated:



please help before i go to sleep
Gil Galvanti
19
Years of Service
User Offline
Joined: 22nd Dec 2004
Location: Texas, United States
Posted: 14th Feb 2005 23:07
heres two pieces of code from something i was working a while back...
This ones the beginning of a paintball course Strategy/Building game (barely got anywhere lol), but its very bugged, such as the wall still "moves" in its coordinates after youve placed it, the wall goes offscreen, and other things, that i never took the time to fix, then i abandoned the project. Here it is, press "W" to make a wall, dont move the mouse before you do or the wall will end up offscreen(it moves kinda fast), click to place, right click to unplace, and you can only make one wall :

You'll have to replace those 2 textures with ur own, or just not use them. Heres something that i asked for help on is creating more than one object, if u still need that(never implemented it into my game):


Video games…they can take you places unreachable, impossible, unfeasible. They put you in the book...they put you in the movie...they put you in a world, a world that before could only be imagined.
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 17th Apr 2005 23:53
Check out my forum post in the code base it might help you it moves objects with the mouse. Im just working out the clicking now. It's only 2 lines of code, well, now that I've added clicking its like 5 but still it should work. Almost done making the clicking version.

Login to post a reply

Server time is: 2024-09-23 17:24:20
Your offset time is: 2024-09-23 17:24:20