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 / My first DBP project. Need assistance with left mouse button events

Author
Message
Poloflece
14
Years of Service
User Offline
Joined: 14th May 2010
Location: Australia
Posted: 28th Mar 2011 12:49
Hi guys

I'm finally getting my head around Dark Basic and I've managed to make a nice fps level with terrain, buildings trees and a player weapon. The problem I've run into is that I cannot get my weapon to shoot, here is the code I'm trying to use .

shoot animation

gunshot sound



Thankyou
Poloflece


Rust Pack WIP here http://forum.thegamecreators.com/?m=forum_view&t=178788&b=24
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 28th Mar 2011 13:07
Not sure about the rest of your code so it's hard to be sure but I guess it could be you are using right clicks too?

If so and you are right clicking when you shoot then mouseclick() will equal 3.

I would tend to check mouseclicks for different values.

Quote: "MOUSECLICK
This command will return an integer value if a mouse button is pressed.

Syntax

Return Integer=MOUSECLICK()

Returns

The left button is assigned a value of 1. The right button is assigned a value of 2. Buttons three and four are assigned values of 4 and 8 respectively. When more than one button is pressed, the value of the buttons are added to produce a combined value you can check for.

Description

The integer return value will depend on which mouse button has been pressed. A mouse can have up to four buttons, and each one can be detected using this command. Each button is assigned a value. The left button is assigned a value of 1. The right button is assigned a value of 2. Buttons three and four are assigned values of 4 and 8 respectively. When more than one button is pressed, the value of the buttons are added to produce a combined value you can check for. "


LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 29th Mar 2011 00:27
Hey PoloFlece,

You do really nice modeling work.

The animation code you have listed will only set the speed of the animation. You would have to use
in order to actually play the animation.

Better yet, why not include the code to include the gunshot sound when the LMB is clicked, like this:


You have to stop the sound like that if you expect it might be playing still from a previous shot. Simply plug in the actual Start Frame and End Frame numbers in order for it to work properly.

Good luck to you,

LB

Poloflece
14
Years of Service
User Offline
Joined: 14th May 2010
Location: Australia
Posted: 29th Mar 2011 09:39
Thankyou, I'll see how it goes

Poloflece


Rust Pack WIP here http://forum.thegamecreators.com/?m=forum_view&t=178788&b=24
Poloflece
14
Years of Service
User Offline
Joined: 14th May 2010
Location: Australia
Posted: 29th Mar 2011 09:49
Yeah I could get the animations to play (for an idle animation) and was trying to use the same code before.
It doesn't play the dound at all


Rust Pack WIP here http://forum.thegamecreators.com/?m=forum_view&t=178788&b=24
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 29th Mar 2011 15:37 Edited at: 29th Mar 2011 15:43
I wrote some quick code so you can test if your sound file is indeed working or not. Plug in your paths / filenames to your model and sound files, save it in your current project directory, reload the project file and run it to see if it works.


For me, this plays the object's animation and plays a ping sound every half second (if I hold the LMB down). You can set the volume of a sound (100 is max), but that usually is not the problem.

Poloflece
14
Years of Service
User Offline
Joined: 14th May 2010
Location: Australia
Posted: 29th Mar 2011 23:39
awesome, it works in the program but when I try it in mine it says "could no close nest at line 183" which is the last line (loop).

Poloflece


Rust Pack WIP here http://forum.thegamecreators.com/?m=forum_view&t=178788&b=24
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 30th Mar 2011 03:02
Check all of the IF / ENDIF codeblocks within your program to make sure you have a matching ENDIF for every IF. Also check DO / LOOP, REPEAT / UNTIL, WHILE / ENDWHILE, etc. Start at line 183 and work your way up from there. Sometimes the error line is not correct, but is in the general area of the actual error. Bear in mind that IF with THEN in the same line does not need an ENDIF.

From your snippets posted I cannot tell if you indent your code, which is good coding practice. You could look at the code I posted as an example of typical indentation if you have not indented it already.

Poloflece
14
Years of Service
User Offline
Joined: 14th May 2010
Location: Australia
Posted: 30th Mar 2011 10:19 Edited at: 30th Mar 2011 10:21
interesting, when I add the code it will work but at the cost of the loss of movement and making the surroundings blank textured.


here's the full code



Thankyou for everyone's help

Edit: the code I posted has the error I'd stated previously

Poloflece


Rust Pack WIP here http://forum.thegamecreators.com/?m=forum_view&t=178788&b=24
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 30th Mar 2011 15:09
You had a REPEAT without an UNTIL in the code. Also, the code to accept mouse button input needs to be in your main do - loop in order to work correctly. Here is an edited version which should work. It does compile fine, but I cannot run it without the media. I indented the code also.



Poloflece
14
Years of Service
User Offline
Joined: 14th May 2010
Location: Australia
Posted: 31st Mar 2011 09:05
Thankyou very much

I'll see how I go about muzzleflash and projectiles


Rust Pack WIP here http://forum.thegamecreators.com/?m=forum_view&t=178788&b=24
Poloflece
14
Years of Service
User Offline
Joined: 14th May 2010
Location: Australia
Posted: 3rd Apr 2011 13:39 Edited at: 3rd Apr 2011 13:40
here's what I've put together so far with your help.
I put a mask sprite over the whole screen just as a test



Poloflece


Rust Pack WIP here http://forum.thegamecreators.com/?m=forum_view&t=178788&b=24
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 3rd Apr 2011 14:59
Looking very sweet, especially for your first DBP project. Did you make the gun, I assume? I like the sprite mask; clever idea. Good work so far.

LB

Poloflece
14
Years of Service
User Offline
Joined: 14th May 2010
Location: Australia
Posted: 3rd Apr 2011 15:19 Edited at: 3rd Apr 2011 15:21
Thanks, the gun is actually from model pack 53 but my friend (also part of subversion) is whipping up some gun designs that I'll model. But I did give the model a custom rig-up

Poloflece


Rust Pack WIP here http://forum.thegamecreators.com/?m=forum_view&t=178788&b=24

Login to post a reply

Server time is: 2024-11-22 23:34:55
Your offset time is: 2024-11-22 23:34:55