Darkbasicpro firing and aiming

Closed Posted Mar 6, 2009 Paid on delivery
Closed Paid on delivery

I Would like for assistance in adding a aiming firing mechanism to my project in dark basic professional.

## Deliverables

Ok, if you are able to syncronize with the mouse when the spacebar is pressed the rotating of the camera(which is coded in already)with the aiming cross-hair and when the the mouse is pressed a firing [url removed, login to view] tried intersect object but cant get the offset limb to move with the cross-hair and camera.

hide mouse

autocam off

Load object "Walkcycle1,22,Waiting23,283,2.x",1

Load object "[url removed, login to view]",2

position object 2, -220,-11,-50

show object 2

Position object 1, x#, 0, z#

yrotate object 1,90

xrotate object 1,90

cy = object size y(1)/2

Position camera x#, cy + 15, z# -50

point camera? 0, cy, 0

set object speed 1,39

show object 1

rem enemy

MAKE OBJECT SPHERE 3,50

COLOR OBJECT 3,RGB(255,000,000)

POSITION OBJECT 3,130,10,500

rem ammo

MAKE OBJECT BOX 4,15,20,50:COLOR OBJECT 4,RGB(000,255,255):POSITION OBJECT 4,140,2,90

EnemyHP#=100

Ammo#=30

MaxAmmo#=30

clips#=3

`perform checklist for object limbs 1

`limb_count = GET LIMB COUNT(1)

`print limb_count

MAKE OBJECT SPHERE 9999,10

`make object sphere 6,10

`position object 6,0,0,-200

`GLUE OBJECT TO LIMB? 6, 1, 32

`position object 9999,0,-1000,-10

MAKE MESH FROM OBJECT 1,9999

DELETE OBJECT 9999

ADD LIMB 1,32,1

OFFSET LIMB 1,32,0,-1000,-10

`DELETE MESH 1

`GLUE OBJECT TO LIMB? 6, 1, 32

Camdist# = 55.0

TrackAngle = 180: Rem 0 - Behind, 180 - Front, 90 & 270 - Sides

CamHeight# = 15.0

Camsmooth = 10

ColFlag = 0

do

rem xxxxxxxxxxxxxxxxxx control player1 xxxxxxxxxxxxxxxxxxxxxxxxxx

`IF KEYSTATE(17)=1 THEN MOVE OBJECT 1,.5

`IF KEYSTATE(31)=1 THEN MOVE OBJECT 1,-.5

`IF KEYSTATE(30)=1 THEN MOVE OBJECT LEFT 1,.3

`IF KEYSTATE(32)=1 THEN MOVE OBJECT RIGHT 1,.3

rem running

`if shiftkey() = 1 and upkey() = 1

`position object 1, x#, 0, z#

`loop object 1,264,286

`x# = newxvalue( x#, object angle y(1), [url removed, login to view] )

`z# = newzvalue( z#, object angle y(1), [url removed, login to view] )

`position camera x#, cy + 15, z# -50

`endif

rem waiting

`print limb_count

if keystate(17) = 0 and spacekey() = 0

`position camera? x#, cy + 15, z# -50

Set Camera To Follow X#, Y#, Z#,WrapValue(Object Angle Y(1)+TrackAngle), Camdist#,Camheight#,Camsmooth,ColFlag

point camera x#, cy, z#

position object 1, x#, y, z#

loop object 1,23,283

endif

rem walk forwards W

if keystate(17) = 1 and spacekey() = 0

position object 1, x#, y, z#

loop object 1,1,22

x# = newxvalue( x#, object angle y(1), [url removed, login to view] )

z# = newzvalue( z#, object angle y(1), [url removed, login to view] )

`position camera x#, cy + 15, z# -50

point camera x#, cy, z#

Set Camera To Follow X#, Y#, Z#,WrapValue(Object Angle Y(1)+TrackAngle), Camdist#,Camheight#,Camsmooth,ColFlag

endif

rem switch view to aiming and firing

if spacekey() = 1

stop object 1

set object frame 1,23

position camera x#, 8, z#

`yrotate camera ay#

`mx = 320

`my = 240

`make object sphere 6,10

`position object 5,mx,my,0

rem get mouse x y

mousex()=mx

mousey()=my

mx = 320

my = 240

`position object 6,mx,my,0

rem draw line from x y

line mx-10 ,my ,mx+10 ,my

line mx ,my-10 ,mx ,my+10

rem xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

rem heres where I need the limb 32,mesh1 to rotate with the camera

rotate camera camera angle x()+mousemovey(),camera angle y()+mousemovex(),0

`ROTATE LIMB mousemovey,32, x, my, z

`GLUE OBJECT TO LIMB? 6, 1, 32

`position object 6,0,0,-200

`Position object 6,object position x(6)+mousemovex(),object position y(6)-mousemovey(),object position z(6)`-mousemovey()

`Position object 1,object position x(1)+mousemovex(),object position y(1)-mousemovey(),object position z(1)`-mousemovey()

`YRotate Limb 1, 32, WrapValue( Limb Angle Y( 1, 32 ) + MouseMoveX( ) )

`rotate limb mousemovex, 32, mx, y, z

rem xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

IF MOUSECLICK()=1

IF Ammo#>0

DEC Ammo#,1

ENDIF

IF OBJECT EXIST(3)=1

IF Ammo#>0

IF INTERSECT OBJECT (3, LIMB POSITION X(1,32), LIMB POSITION Y(1,32), LIMB POSITION Z(1,32), OBJECT POSITION X(1),OBJECT POSITION Y(1), OBJECT POSITION Z(1))>0

DEC EnemyHP#,1

ENDIF

ENDIF

ENDIF

ENDIF

rem

endif

IF EnemyHP#=0

IF OBJECT EXIST(3)=1

DELETE OBJECT 3

ENDIF

ENDIF

rem reload with R if ammo = 0

IF KEYSTATE(19)=1 AND Ammo#=0

if clips#>=1

Ammo#=MaxAmmo#

clips#=clips#-1

endif

if clips#=<0 and ammo#=0

clips#=0

endif

endif

IF OBJECT EXIST(3)=1

CENTER TEXT OBJECT SCREEN X(3),OBJECT SCREEN Y(3)-70,"Enemy Health: "+str$(EnemyHP#)

ENDIF

rem print ammo

TEXT 0,SCREEN HEIGHT()-50,"Ammo: "+str$(Ammo#)

IF OBJECT EXIST(4)=1

IF clips#<=2 AND INTERSECT OBJECT (4, OBJECT POSITION X(1),OBJECT POSITION Y(1)-25,OBJECT POSITION Z(1),OBJECT POSITION X(1),OBJECT POSITION Y(1),OBJECT POSITION Z(1))>0

rem pick up ammo

IF INTERSECT OBJECT (4, OBJECT POSITION X(1),OBJECT POSITION Y(1)-25,OBJECT POSITION Z(1),OBJECT POSITION X(1),OBJECT POSITION Y(1),OBJECT POSITION Z(1))>0

INC Clips#

`INC Ammo#,(MaxAmmo#-Ammo#)

DELETE OBJECT 4

ENDIF

endif

endif

rem print clips

TEXT 0,SCREEN HEIGHT()-40,"Clips: "+str$(Clips#)

Rem Left and Right A+D

If keystate(30)=1 then aY# = Wrapvalue(aY#-3)

If keystate(32)=1 then aY# = Wrapvalue(aY#+3)

`rem rotate the Player1

Yrotate object 1,aY# + 180

`yrotate camera ay#

rem xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

loop

Engineering Game Consoles Game Design Microsoft MySQL PHP Project Management Software Architecture Software Testing Windows Desktop

Project ID: #3702160

About the project

Remote project Active Mar 28, 2009