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 newbie here, please help!

Author
Message
Lega
21
Years of Service
User Offline
Joined: 10th Aug 2003
Location: United States
Posted: 11th Aug 2003 03:33
This Dark BASIC is one of the simplist languages I have ever learned. But I'm still having some problems with it unfortunately. I have so far made one little program where you put in ten words and it sprays them across the screen randomly and in random colors. But now I'm trying to make something a bit more difficult. I have the Mutant from the DarkMATTER area as my 3D Player object. Right now all it does is stay in the idle pose (even when you move it.) I have a few questions regarding my programming. 1. I would like to know how to put a camera behind it's head, like 3rd person view, and no, the tutorial on the site didn't help. It keeps doing wierd things whenever I use that code. 2. I want to make it so the Mutant changes to a walking pose whenever the up key is pressed. I would really appreciate any an all help. So thanks. Oh, and for refrence I posted my code that I have so far.
In the code (I copied it from the manual.) I don't understand anything related with the stage variable, help with that would be appreciated also. Thanks to anyone who makes an effort to help!
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 11th Aug 2003 07:57
There is some code that comes with DB that does just this. Look in the examples and projects directories - would help but have to go.

RPGamer

Current Project: Eternal Destiny
Porting all files to my new computer
Lega
21
Years of Service
User Offline
Joined: 10th Aug 2003
Location: United States
Posted: 11th Aug 2003 08:26
I know that there is some code that comes with DB, but I can't seem to get it to work. Unfortunately.

"Something wicked this way co- oh, wait, it took a left."
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 11th Aug 2003 09:34
Look up Set Camera To Follow in the help. That's the command you need.

TDK
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 11th Aug 2003 16:53
hints

you need to play the object animation
if you had the camera at the same position as the object (something like position camera object x,y,z and with the camera at the same orientation then you could move it backwards a bit and it would be behind the object
or you could make the camera follow as indi said
IIRC you will need to load both idle.x and walk.x and then find some way to append one animation onto the other, then you need some way to chose the frame the animation starts from.

this is my new idea for help, if you think it sucks or is too cryptic then let me know (well people learn nothing if you just give em the code), cheers.

Mentor.

Lega
21
Years of Service
User Offline
Joined: 10th Aug 2003
Location: United States
Posted: 11th Aug 2003 17:36
Thanks for all you guys help! I think now I'm able to get the camera to always follow the Mutant now. I haven't teseted prolonged amounts of time though. I'm still kind of shaky on the switching poses though. But I do think this is the code:

LOAD OBJECT "idle.x",1 : APPEND OBJECT "walk.x"

Tell me what ya think.

"Something wicked this way co- oh, wait, it took a left."
Lega
21
Years of Service
User Offline
Joined: 10th Aug 2003
Location: United States
Posted: 11th Aug 2003 18:14
Argh. Again I'm having problems with my camera, all though this time it DOES follow the Player object. I have posted a pic to show what is happening.

http://www.freewebs.com/lega669/CamMess.bmp

And here is my new code:


rem Make four walls
make object box 1,10,200,1000 : position object 1,-500,100,0 : color object 1,rgb(155,40,20)
make object box 2,10,200,1000 : position object 2, 500,100,0 : color object 2,rgb(155,40,20)
make object box 3,1000,200,10 : position object 3, 0,100,-500 : color object 3,rgb(155,40,20)
make object box 4,1000,200,10 : position object 4, 0,100, 500 : color object 4,rgb(155,40,20)

rem Make a floor and create texture for it
make object box 5,1000,10,1000 : position object 5,0,-5,0 : color object 5,rgb(0,255,0)
create bitmap 1,32,32 : cls rgb(0,155,0) : ink rgb(0,145,0),0 : box 4,4,12,12
get image 1,0,0,32,32 : delete bitmap 1 : texture object 5,1
scale object texture 5,200,200

rem Load texture for the player object.
LOAD BITMAP "alien2.bmp",1
GET IMAGE 1,0,0,512,512
DELETE BITMAP 1

rem Load 3D object and append idle data to it (idle.)
LOAD OBJECT "idle.x",1 : APPEND OBJECT "walk.x",1,100
YROTATE OBJECT 1,170 : FIX OBJECT PIVOT 1

rem Loop 3D object animtaion from 0 to (idle.)
LOOP OBJECT 1,0,100 : SET OBJECT SPEED 1,5
TEXTURE OBJECT 1,1

rem Activate manual syncronization
SYNC ON

rem Begin loop
DO

rem Store old positions
oldposx#=object position x(1)
oldposy#=object position y(1)
oldposz#=object position z(1)

rem Modify character angle based on left/right keys.
stage=0
IF LEFTKEY()=1 THEN a#=a#-8.0
IF RIGHTKEY()=1 THEN a#=a#+8.0
a#=wrapvalue(a#)

rem Modify character position based on up/down keys.
IF UPKEY()=1 THEN x#=NEWXVALUE(x#,a#,0.5) : z#=NEWZVALUE(z#,a#,0.5) : stage=1 : erase=1
IF DOWNKEY()=1 THEN x#=NEWXVALUE(x#,a#,-0.5) : z#=NEWZVALUE(z#,a#,-0.5) :stage=1

rem If character action changes.
IF stage<>oldstage
IF stage=0
SET OBJECT FRAME 1,0.0
LOOP OBJECT 1,0,20
SET OBJECT SPEED 1,5
ENDIF
oldstage=stage
ENDIF

rem Update character position and angle.
POSITION OBJECT 1,x#,0.0,z#
YROTATE OBJECT 1,a#

rem Get current object position
posx#=object position x(1)
posy#=object position y(1)
posz#=object position z(1)

rem Update with new object position
position object 1,posx#,posy#,posz#

rem Use camera tracker to follow player object
angle#=object angle y(1)
camdist#=25.0 : camhigh#=posy#+10.0 : camfade#=3.5
set camera to follow posx#,posy#,posz#,angle#,camdist#,camhigh#,camfade#,1

rem Refresh screen.
SYNC

rem End loop.
LOOP

Unfortunately some of it has to be pushed over and down. I won't quit this thing until I get it right!

"Something wicked this way co- oh, wait, it took a left."
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 11th Aug 2003 19:21 Edited at: 11th Aug 2003 19:24
reduce the values in camdist# and camhi# and all should be well, the code you posted was very muddled, heres it without loaded textures and sorted out a bit, as you had it the middle of the player object (the sphere I added)would have been in the middle of the floor, so I increased the height, just set that to whatever puts the characters feet on the floor, if you read the help it says what each of the numbers do, I threw out all the calculations since a lot of them where of no use for this setup anyway, this works fine, hope you can see what it`s doing.


rem Make a floor and create texture for it
make object box 5,1000,10,1000 : position object 5,0,-5,0 : color object 5,rgb(0,255,0)
create bitmap 1,32,32 : cls rgb(0,155,0) : ink rgb(0,145,0),0 : box 4,4,12,12
get image 1,0,0,32,32 : delete bitmap 1 : texture object 5,1
scale object texture 5,200,200
rem this is now the player object
make object sphere 8,1
TEXTURE OBJECT 8,1
position object 8,5,0.5,0
rem Activate manual syncronization
SYNC ON
a#=0
DO
rem Store old positions
oldposx#=posx#
oldposy#=posy#
oldposz#=posz#
rem Modify character angle based on left/right keys.
stage=0
IF LEFTKEY()=1 THEN a#=a#-1.0
IF RIGHTKEY()=1 THEN a#=a#+1.0
a#=wrapvalue(a#)
rem Modify character position based on up/down keys.
yrotate object 8,a#
IF UPKEY()=1 THEN move object 8,1
IF DOWNKEY()=1 THEN move object 8,-1
rem Get current object position
posx#=object position x(8)
posy#=object position y(8)
posz#=object position z(8)
rem Use camera tracker to follow player object
set camera to follow posx#,posy#,posz#,a#,5,1,5,1
rem Refresh screen.
SYNC
rem End loop.
LOOP

I pulled the animation/walls since I didn`t want to go to the trouble of finding the model, you had also given the player object the same model number as the wall (1), so I don`t know how on earth you managed to get that screenshot , also you had made the walls from boxes, there is no need to do that, just use plains, this isn`t the real world, you can have an infinitley thin wall made of bricks and it saves on the poly count (10 as against 60), apart from that you just needed to move the camera closer and lower, cheers.

Mentor.

Lega
21
Years of Service
User Offline
Joined: 10th Aug 2003
Location: United States
Posted: 12th Aug 2003 03:56
How strange about the object thing, but did you notice how the floor was textured with the skinf of the mutant I was using? Anyway, thanks for all your help, this should work perfectly now. Thank you everyone for trying to help also. I can now start back on my game!

"Something wicked this way co- oh, wait, it took a left."
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 12th Aug 2003 05:38
I see you got the object animation tut in there

Current Project: Eternal Destiny
Porting all files to my new computer
Lega
21
Years of Service
User Offline
Joined: 10th Aug 2003
Location: United States
Posted: 12th Aug 2003 06:22
Yep. But alas, I have another problem, the camera is NOW FIXED! YAHOO! But, I can't make it so the Player object (the mutant ) changes poses when walking. It is very wierd to. It does one idle pose, then it freezes on one frame for A LONG time, then it shows the walking animation, then it does the idle pose and repeats again by freezing in that frame. I can still move it around when it is frozen and everything, in its animations to. But it just doesn't work. Sorry for all the n00bish questions. Any help would be appreciated.

"Something wicked this way co- oh, wait, it took a left."
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 12th Aug 2003 14:14 Edited at: 12th Aug 2003 14:26
try this thread

http://www.darkbasicpro.com/apollo/view.php?t=14966&b=7

that explains appending and calling stages, just make sure you call the sequence once per cycle instead of calling it over and over, that can cause "lockups" since it plays the first frame repeatedly, cheers.

Mentor.

Lega
21
Years of Service
User Offline
Joined: 10th Aug 2003
Location: United States
Posted: 12th Aug 2003 20:53
Thanks for that bit of code Mentor, but unfortunately it gives me an error everytime I try to run the game. It gives me the error:

ERROR AT LINE 15. APPEND FRAME MUST BE GREATER THAN MODELS TOTAL FRAME COUNT.

And here is the code:

rem Make a floor and create texture for it
make object box 2,1000,10,1000 : position object 2,0,-5,0 : color object 2,rgb(0,255,0)
create bitmap 2,32,32 : cls rgb(0,155,0) : ink rgb(0,145,0),0 : box 4,4,12,12
get image 2,0,0,32,32 : delete bitmap 2 : texture object 2,2
scale object texture 2,200,200
rem Load texture for the player object.
LOAD BITMAP "alien2.bmp",1
GET IMAGE 1,0,0,512,512
DELETE BITMAP 1
rem Load 3D object and append idle data to it (idle.)
load object "idle.x",1
idle=total object frames(1)
append object "walk.x",1,idle
walk=total object frames(1) <--- This is where the error happens.
texture object 1,1
rem Activate manual syncronization
SYNC ON
a#=0
rem Begin loop
DO
rem Store old positions
oldposx#=object position x(1)
oldposy#=object position y(1)
oldposz#=object position z(1)
rem Modify character angle based on left/right keys.
stage=0
IF LEFTKEY()=1 THEN a#=a#-1.0
IF RIGHTKEY()=1 THEN a#=a#+1.0
a#=wrapvalue(a#)
rem Modify character position based on up/down keys.
yrotate object 1,a#
IF UPKEY()=1 THEN move object 1,1 : play object 1,idle+1,walk
IF DOWNKEY()=1 THEN move object 1,-1
rem Get current object position
posx#=object position x(1)
posy#=object position y(1)
posz#=object position z(1)
rem Update with new object position
position object 1,posx#,posy#,posz#
rem Use camera tracker to follow player object
angle#=object angle y(1)
camdist#=5.0 : camhigh#=1.0 : camfade#=3.5
set camera to follow posx#,posy#,posz#,angle#,camdist#,camhigh#,camfade#,1
rem Refresh screen.
SYNC
rem End loop.
LOOP

Again, thanks for any help!

"Something wicked this way co- oh, wait, it took a left."
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 12th Aug 2003 22:49
oops! my bad, forgot the offset to get above the idle frames, just add one to the idle variable like this...

append object "walk.x",1,idle+1

the error message was telling you that the new frames where trying to ovewrite the idle animations last frame, sorry about that.

Mentor.

Lega
21
Years of Service
User Offline
Joined: 10th Aug 2003
Location: United States
Posted: 12th Aug 2003 23:58
Thanks!

"Something wicked this way co- oh, wait, it took a left."

Login to post a reply

Server time is: 2024-09-20 19:34:26
Your offset time is: 2024-09-20 19:34:26