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 / A simple rifle sight help

Author
Message
paulhenry
16
Years of Service
User Offline
Joined: 20th Jun 2008
Location:
Posted: 8th Feb 2009 21:36
Would anybody know a simple technique for a sight,just a cross hair or something easy to show when the spacebar is pressed and for the camera to change from 3rd person view to 1st person view,so alls that is showing is the sight,to be controlled by the mouse please.
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 8th Feb 2009 22:35
How's this?

Feel free to ask questions.

BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 8th Feb 2009 22:45 Edited at: 8th Feb 2009 22:51
Edit: Ninja'd!
Wow, that's funny, we wrote almost the exact same code

Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 8th Feb 2009 22:49
Yup, we did...
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 8th Feb 2009 22:51
Hmm, yours seems to be smoother, so I've removed mine to avoid confusion .

Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 8th Feb 2009 22:52
Oh dear. Well thankee. I'm flattered.
paulhenry
16
Years of Service
User Offline
Joined: 20th Jun 2008
Location:
Posted: 8th Feb 2009 23:14
Many thanks but I already have a player1,could you please ammend the code to remove everything except the sight,to be controlled by the mouse and the spacebar.
lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 8th Feb 2009 23:14
wow that never happened before, my video driver stopped working whenever i run this code, i just wanted to see what it was...
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 8th Feb 2009 23:25
Quote: "Many thanks but I already have a player1,could you please ammend the code to remove everything except the sight,to be controlled by the mouse and the spacebar."


Um, not really, considering I have no idea of how you've structured your code...

controls object rotation with the mouse...

controls camera positioning...

But really, if you're just going to cut and paste, you'll never understand it. Dissect my code and determine for yourself what you need from it...
paulhenry
16
Years of Service
User Offline
Joined: 20th Jun 2008
Location:
Posted: 8th Feb 2009 23:43
many thanx,ill post my code for you to adapt after you tell me how to get the box up in which you put your code,pressing the code button just brings up the text .
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 8th Feb 2009 23:47
Highlight the code and then press the button.

Um, I'm not going to write your code for you... I just gave you an example of what you wanted to do... adapting it is your job. It's how you learn.
paulhenry
16
Years of Service
User Offline
Joined: 20th Jun 2008
Location:
Posted: 8th Feb 2009 23:57
hide mouse
rem loading paratrooper
rem select font
set text font "arial" : set text size 16
set text to bold : set text transparent

rem Loading prompt
center text screen width()/2,SCREEN HEIGHT()/2,"LOADING"
WAIT 3000
CLS
center text screen width()/2,screen height()/2,"PARATROOPER"
WAIT 3000
CLS

sync on
rem sync rate 60
Rem Load Media
Rem xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
load object "NewwaitingwithSA80,10.x",1
load object "NewwalkcyclewithSA80,4.x",2
load object "NewAIMwithSA80,1.x",3
load object "NewHOLDAIMwithSA80,1.x",4
rem load object "NewdownriflewithSA80.x",5

load sound "jungle.ogg",1
load image "Grasstexture1.jpg",1
rem sights xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


REm xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
rem Variables
Health = 100

rem load world or make matrix
make matrix 1, 2000, 2000, 25, 25
position matrix 1,-600, -20, -300
randomize matrix 1,rnd(10)
set matrix wireframe off 1
prepare matrix texture 1, 1, 1, 1
update matrix 1

rem xxxxxxxxxxxxxxxxxx
cy = object size y(1)/2
position camera 100, cy, -20
point camera 0, cy, 0

hide object 2
position object 2, x#, 0, z#
xrotate object 2,90
position object 1, x#, 0, z#
xrotate object 1,90
hide object 3
position object 3, x#, 0, z#
xrotate object 3,90
hide object 4
position object 4, x#, 0, z#
xrotate object 4,90
`hide object 5
`position object 5, x#, 0, z#
` xrotate object 5,90





rem play background music
loop sound 1

REM START LOOP
DO

rem xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
rem incandDec health
box 430, 10, Health*2+430, 20, rgb(255,0,0), rgb(255,0,0), rgb(0,255,0), rgb(0,255,0)
if inkey$() = "a"
dec Health
if Health < 0 then Health = 0
endif

if inkey$() = "q"
inc Health
if Health > 100 then Health = 100
endif

rem xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Rem control Player1

IF UPKEY() = 0
HIDE OBJECT 2
SHOW OBJECT 1
set object speed 1,7
LOOP object 1,23,265
position object 1, x#, 0, z#
ENDIF


if upkey() = 1
hide object 1
stop object 1
set object frame 1,0
rem xxxxxxxxxxxxxxxx
rem stop loop object 1 and reset animation
rem xxxxxxxxxxxxxxxx
rem move player forward
x# = newxvalue( x#, object angle y(2), -0.03 )
z# = newzvalue( z#, object angle y(2), -0.03 )
rem show animation 2xxxxxxxxxxxxxxxxxxxxxxx
show object 2
set object speed 2,7
LOOP object 2,1,22
position object 2, x#, 0, z#
ENDIF
Rem xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Rem AIMING
`if spacekey() = 0
`endif




if spacekey() = 1
hide object 1
stop object 1
set object frame 1,0
hide object 2
stop object 2
set object frame 2,0
set object speed 3,5
show object 3
loop object 3,24,36
position object 3, x#, 0, z#
rem swap to holding aim
stop object 3
hide object 3
set object frame 3,24
show object 4
loop object 4,36,56
position object 4,x#, 0, z#



endif

if spacekey() = 0
stop object 3
set object frame 3,0
hide object 3
stop object 4
set object frame 4,23
hide object 4

endif

rem hide object 3
rem loop object 4,25,43


Rem Left and Right

If Leftkey()=1 then aY# = Wrapvalue(aY#-1)

If Rightkey()=1 then aY# = Wrapvalue(aY#+1)

rem rotate the sphere
Yrotate object 1,aY#
yrotate object 2,ay#
yrotate object 3,ay#
yrotate object 4,ay#
sync

LOOP
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 9th Feb 2009 01:22
...are you waiting for me to fit my code into yours?

Quote: "Um, I'm not going to write your code for you... I just gave you an example of what you wanted to do... adapting it is your job. It's how you learn. "


I said I wouldn't do it... I think you can do it yourself. I've given you an example of it, now you need to figure out how to apply it.

Login to post a reply

Server time is: 2024-11-25 10:45:01
Your offset time is: 2024-11-25 10:45:01