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 / Mouse Click engine

Author
Message
They Killed Kenny
20
Years of Service
User Offline
Joined: 18th Jul 2004
Location: FL, USA
Posted: 14th Nov 2004 08:43 Edited at: 14th Nov 2004 08:45
Ok, I have this game I wanna make and I want the controls to be the mouse. There will be a sprite and some ground from isometric view. I'm using DBpro

You select the sprite by clicking it and then right-click on the ground to make it move to that location.

I was thinking of using something like:



Is this code ok? Is there any way that is more efficient?
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 14th Nov 2004 13:47
I'm guessing you've written this without testing it?

Interesting use of do loops. I've only ever seen one do loop per routine - if you do it like you have, you will need a sync in each loop to see your sprite moving, and even then it's going to move only along the x-axis in the first loop until it gets to the 'futuremouse' (sounds like a superhero cartoon character) position, and then seperately along the y-axis in the next loop.

Also I'm not sure about your syntax for the mouse click command - isn't it more like 'if mouseclick()=1 then' etc...?


Harvester
20
Years of Service
User Offline
Joined: 17th Sep 2004
Location: Infront of my computer
Posted: 14th Nov 2004 13:58 Edited at: 14th Nov 2004 14:12
Well, I'm no coding expert, but you will also need some code for when the user clickes behind the player



their might be a faster way, and I would add some error checking
just to make sure I don't accidentaly move right past the Futer_X or Futer_Y location, but that should work.
Hope I helped!

EDIT As Ric pointed out, the sync commands are inside of 4 different loops, and the character doesn't move along both of the locations at the same time. So, a better way to do it(now that I have had longer to think about it) is this :



I think that will work better

Someday, I'll finish a game. Until then, I'll just start writting them.
They Killed Kenny
20
Years of Service
User Offline
Joined: 18th Jul 2004
Location: FL, USA
Posted: 14th Nov 2004 23:23
ok that would explain why my code is not working... lol

I've been rying to figure out mosclick's syntax for weeks... thanks for the help!
They Killed Kenny
20
Years of Service
User Offline
Joined: 18th Jul 2004
Location: FL, USA
Posted: 16th Nov 2004 10:39 Edited at: 16th Nov 2004 11:16
:S its not exactly working.... It moves everything Gradually along the X axis and it doesnt across the y axis. It just moves teh sprite to the position it supposed to be without doing it gradually.


nvm u had a typo in ur code... where it should have said y it said x...

now i have a different problem.. I dont want it to work while I hold the mouse. If you were to click while the sprite was moving, it supposed over-ride the old move command, and it does that... but it also works if you hold the mouse...



the image for the sprite is attached to the post... It's very simple since I'm barely getting the game to work...

Attachments

Login to view attachments
Harvester
20
Years of Service
User Offline
Joined: 17th Sep 2004
Location: Infront of my computer
Posted: 17th Nov 2004 04:13 Edited at: 17th Nov 2004 04:16
If you want the character to stop moving when you hold the mouse button down, I am not entirly sure how to do that I don't think darkbasic has a command to find out if the mouse has been held down or not, so you will have to code your own. This is obviously not going to be really simple, but I'll try and help. For starters, we will have a function the you call when the mouse is clicked, and we will call this function Check_For_Mouse_Hold()
Here is some code



Now, the place to put that function call, and a bit more code, is right about here inside the origianl program



This code (mostly my function right now) still needs a lot of work, perhapes a way to check for the mouse hold without entering a loop, as this will cause a "glitch" if the user hold the mouse button down. Maybe someone has an idea? Untill later, Good Luck!

P.S sorry about the typo, since they both needed the same kind of statments I just copy/pasted it, and then forgot to change the variable names

Someday, I'll finish a game. Until then, I'll just start writting them.
They Killed Kenny
20
Years of Service
User Offline
Joined: 18th Jul 2004
Location: FL, USA
Posted: 17th Nov 2004 07:56 Edited at: 18th Nov 2004 05:09
It's not exactly what i want... I want to stop the mouse position from going into futer_X and FUTER_Y if the player hold down the mouse... If they click... then the new position gets logged as FUTRE XY

It's based on this game I have.... I can get you a download of the demo

Here It is: You have to make a Fileplanet account though...
http://www.fileplanet.com/files/10000/11510.shtml
Harvester
20
Years of Service
User Offline
Joined: 17th Sep 2004
Location: Infront of my computer
Posted: 18th Nov 2004 11:45 Edited at: 18th Nov 2004 11:48
For no good reason, I don't like Gamespy that much, so if I am not right with the following code, just give a more detailed description

So you want the guy to keep moving in towards the point he was moving to if you hold the mouse down? Just so I know I am understanding you , an example : Guy is moving towards x point of 70, y point of 70. You click(NOT hold) the mouse at x point 170, y point 170. Guy is now moving towards x point 170, y point 170. You click and HOLD the mouse button at x point 230, y point 230. Guy keeps moving towards x point 170, y point 170. If that is what you want, then just add some variables to hold the x and y location points (Temporary_Futer_X, Temporary_Futer_Y). If the user holds the button down for the needed amount, just set Futer_X to Temporary_Futer_X, and Futer_Y to Temporary_Futer_Y. Were you set the Temporary_ variables, I am not sure, so experemint a little

Someday, I'll finish a game. Until then, I'll just start writting them.
Neofish
20
Years of Service
User Offline
Joined: 7th Apr 2004
Location: A swimming pool of coke
Posted: 18th Nov 2004 23:56 Edited at: 18th Nov 2004 23:57
I haven't read this thread properly but there are a couple ways of doing it. To check if the sprite is clicked you can either check for collision (sprite collision commands in help) or check the mouse positions (x and y) against the sprite position (also x and y) when the mouse is clicked. Then you have to move it. I haven't done this with sprites so I'll give the 3D version. Rotate it to face the point where the mouse is onClick (x and y) and then move it until it reaches that point. All you need is two variables to hold the destination, as the clicks are done at run-time, but you don't want to have to hold the mouse.

Hope this helps (I'm at work experience so I have time to wake up)
N30F15H

EDIT:
Quote: "time to wake up"

wtf...I'm sure I wrote time to write this......

[center]int N30F15H,a=1; do { N30F15H++; } while (a==1);
[center]
They Killed Kenny
20
Years of Service
User Offline
Joined: 18th Jul 2004
Location: FL, USA
Posted: 19th Nov 2004 05:37 Edited at: 19th Nov 2004 05:38
Ok... ...
what?

ok

Quote: "
For no good reason, I don't like Gamespy that much, so if I am not right with the following code, just give a more detailed description "


um its not gamespy.. its fileplanet... oo
I edited the post...

I hate Gaymspy too, primarily because they keep doing maintenance on the server of my most favorite computer game... and just when you think you can start playing... they take the server down again >.>
Harvester
20
Years of Service
User Offline
Joined: 17th Sep 2004
Location: Infront of my computer
Posted: 19th Nov 2004 06:30 Edited at: 19th Nov 2004 06:31
Sorry, didn't see the edit. Sadly, when I try and download the game(or any fileplanet download for that matter), it asks for my gamespy acount info(which I don't remember and can't get back because my e-mail has changed since I registerd) You can get a fileplanet acount, but that costs money

Someday, I'll finish a game. Until then, I'll just start writting them.
They Killed Kenny
20
Years of Service
User Offline
Joined: 18th Jul 2004
Location: FL, USA
Posted: 19th Nov 2004 06:39
no it doesnt
i got mine for free...
Harvester
20
Years of Service
User Offline
Joined: 17th Sep 2004
Location: Infront of my computer
Posted: 19th Nov 2004 10:50
Well That's good news! Maybe when I'm downloading mods for morrowind......Anyway, how is the mouse engine coming along?

Someday, I'll finish a game. Until then, I'll just start writting them.
They Killed Kenny
20
Years of Service
User Offline
Joined: 18th Jul 2004
Location: FL, USA
Posted: 20th Nov 2004 09:20
I'm a n00b not a miracle worker lol...

It's almost the same as last time... i tried doing the function thing, but it was too dificult for me..
Harvester
20
Years of Service
User Offline
Joined: 17th Sep 2004
Location: Infront of my computer
Posted: 20th Nov 2004 14:43
Everybodys a newb at some point

Quote: "... i tried doing the function thing..."


Do you mean the part about Old_Futer_X & Y? Those don't actualy go into the function, they get placed in the main loop. This is becuase the function only tells the program wether the mouse button has been held down or not, it doesn't modify any values other than Mouse_Held_Down. As to were they get placed...well, this part is a bit trickyer, so I'll explain it if this happens to be the problom(I'm lazy right now )

Someday, I'll finish a game. Until then, I'll just start writting them.
They Killed Kenny
20
Years of Service
User Offline
Joined: 18th Jul 2004
Location: FL, USA
Posted: 27th Nov 2004 07:00
er... I don't exactly know how to program a game of this magnitude, so does anyone have a tutorial for somethin i could program?

Login to post a reply

Server time is: 2024-11-13 18:41:01
Your offset time is: 2024-11-13 18:41:01