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.

DarkBASIC Professional Discussion / I dont quite get this about when character attack enemy

Author
Message
Andrew
22
Years of Service
User Offline
Joined: 23rd Aug 2003
Location: United Kindom (what makes it important?)
Posted: 14th Sep 2003 17:07
Well what i want to know is.
If i have a character, if i click the attack button to attack an enemy, will it load a different model, like a model of the character attacking?
If so could you show me a quick code please, just an example, doesn't need to be long
Thanks a lot - I'm learning lots more now, but need quick help on understanding this.

Thanks
Mentor
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 14th Sep 2003 17:29
there seems to be some misunderstanding here. have you tried the examples and tutorials off the site?, take a look at the codebase as well, to answer your question, your object would have the animation included or coded into it`self, either because you loaded and appended the animation, or because it had the animation built into it, then you code for the button and the collision with the pointer and when they collide and the mouse button is clicked then you start that specific animation sequence running, a quick example isn`t that easy to follow since it covers a lot of darkbasic functions, start out simpler, just load an object and get it to move, then load another and get it to follow the first one around, thats enough to be going on with for now, cheers.

Mentor.
Andrew
22
Years of Service
User Offline
Joined: 23rd Aug 2003
Location: United Kindom (what makes it important?)
Posted: 14th Sep 2003 17:39 Edited at: 14th Sep 2003 17:42
So i can load a 3DS file and if i put it all together, it would animate?
(Not forgetting the x.file too)
Andrew
22
Years of Service
User Offline
Joined: 23rd Aug 2003
Location: United Kindom (what makes it important?)
Posted: 14th Sep 2003 18:00
I get the idea, basically if i wanted the character to attack i would make.
rem make character attack
gosub_character_attack

_character_attack
Then place the code for a certain button to be pressed and the object load for the attack like character1.x


Does this sound correct, i know i have to add more codes in the _character_attack, but this is what i would basically but in.....
Right?
Mentor
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 14th Sep 2003 18:25
you only need to load an x file, they are more compatable with DB anyway, some people report problems with some 3DS files, if you do this

sync on
Sync Rate 0
hide mouse
load object "ColZ_Run.x",1
xrotate object 1,-90
yrotate object 1,90
loop object 1
set object speed 1,600
do
sync
loop

it will load an object and run the animation, if you are using pro then this model (colz_run.x) will be in your media folder inside the pro install folder, just start a new project and then open the projects folder and open the folder that has the name of your project and put the colz model and the texture (has the same name) in the folder before you compile, cheers.

Mentor.
Andrew
22
Years of Service
User Offline
Joined: 23rd Aug 2003
Location: United Kindom (what makes it important?)
Posted: 14th Sep 2003 18:30
Can i also have a gosub code like the one above that i have explained?
zircher
23
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 14th Sep 2003 18:35
The commands you're looking for is PLAY OBJECT and LOOP OBJECT. These commands will play embeded animations that your 3D modelling guy has added to a model.

From the AlienDemo...

rem Numerics for Animations
k$=lower$(inkey$())
if k$="a" then loop object 1,0,100 : desc$="IDLE"
if k$="b" then loop object 1,100,150 : desc$="IMPACT"
if k$="c" then loop object 1,150,200 : desc$="ATTACK 1"
if k$="d" then loop object 1,200,250 : desc$="FALL DOWN"
if k$="e" then loop object 1,250,300 : desc$="GET UP"
if k$="f" then loop object 1,300,350 : desc$="ATTACK 2"
if k$="g" then loop object 1,350,400 : desc$="DUCK"
if k$="h" then loop object 1,400,500 : desc$="DANCE"
if k$="i" then loop object 1,500,550 : desc$="JUMP 1"
if k$="j" then loop object 1,550,650 : desc$="JUMP 2"
if k$="k" then loop object 1,670,720 : set object frame 1,650 : desc$="WALK"

Here we can see that by pressing certain keys, the alien model will execute specified animation sequences. For example, pressing the 'i' key will play frames 500 to 550 of the model.

What this really means for the coder is that you can NOT play a 3D animation unless it has been added to the model and you know exactly when to start and when to stop an animation sequence. *
--
TAZ


* Well, you could programatically move and rotate each limb of a model, but that would be pretty insane since you would be coding dozens if not hundreds of lines to do the same thing as one PLAY OBJECT or LOOP OBJECT command.
Mentor
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 14th Sep 2003 18:36 Edited at: 14th Sep 2003 18:42
don`t ever load a model during the game since it will slow the game down massivley, load all those you need for the level before the game starts, if you have an object loaded like "superninja_idle.x" and you want him to attack as well as stand fiddling with his shurikens then you append the animation onto him, for example if the idle animation ends at frame 20 then do

append object "superninja_attack.x",99,21

this adds the animation superninja_attack.x to the superninja_idle.x animation that was already loaded as object 99, and since the last frame of the idle animation was 20 the first frame for attack will become 21, then when you want him to go from idle to attack do

play object 99,21

and he starts from frame 21 and goes through the attack sequence then stops, ok?

Mentor.

ps: yes you can gosub or call a function, it`s your code, do whatever you like, as long as you understand it and feel comfortable then thats fine, worry about the finer points of code when you can make working code on your own
Andrew
22
Years of Service
User Offline
Joined: 23rd Aug 2003
Location: United Kindom (what makes it important?)
Posted: 14th Sep 2003 18:45
Ah i get the idea now on what you are saying.
Do you now the source code you said
I would have to load the actual objects first, so would i simply have a code like load object="JUMP1.x" and then make commands like if k$="j" then loop object 1,550,650 : desc$="JUMP 2"
Then sort out what happens when that is pressed, eg enemy's health goes down etc
Mentor
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 14th Sep 2003 18:54 Edited at: 14th Sep 2003 18:58
yes, but the desc$="jump 2" bit is just a part of the demo program that got carried over, you don`t need to do that bit, unless you plan to print jump 2 onto the screen or something, just the bit up to the colon will be ok, just note that your number in the loop instruction have to refer to the frames in the animation of your model, those will most likley only work for the competition alien animations since only that model will most likley have those animations at those positions.

Mentor.
Andrew
22
Years of Service
User Offline
Joined: 23rd Aug 2003
Location: United Kindom (what makes it important?)
Posted: 14th Sep 2003 19:00 Edited at: 14th Sep 2003 19:01
OK so say i do this source code, right.
Now how do i make sure that when the character hit's the enemey with a sword or something, it will take it's health down.
I tried looking for this at the demo, but it allways has something to do with a gun.
David T
Retired Moderator
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 14th Sep 2003 19:06
Okay, here is the way I do it. Not very advanced but it works.



c:/dos
c:/dos run
run dos run
Andrew
22
Years of Service
User Offline
Joined: 23rd Aug 2003
Location: United Kindom (what makes it important?)
Posted: 14th Sep 2003 19:08
MMM, but how would i make sure it would take the enemies health down?
Mentor
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 14th Sep 2003 19:14 Edited at: 14th Sep 2003 19:15
position the sword in the players hand and then once you have found the limb number for that arm then use the "glue object to limb" command to attach the sword to the arm, you then use rotate limb to move the arm (or the arm may be animated in the attack animation) and then check for the sword colliding with the enemy, when the sword hits the enemy you can do something like

if object collision (sword,enemy) then dec enemylifepower

and then to check if he died do

if enemylifepower < 0 then gosub death_animation

thats all there is to it, think of darkbasic as a languge and then think how you would tell someone to do something useing just the words in the language, you will find there is a way to make instructions for anything you want to do, you just need to work out what commands will do what you want in the correct order, cheers.

Mentor.
David T
Retired Moderator
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 14th Sep 2003 19:15


It's up to you how you store the health. I'd store it in an array.

c:/dos
c:/dos run
run dos run
Andrew
22
Years of Service
User Offline
Joined: 23rd Aug 2003
Location: United Kindom (what makes it important?)
Posted: 14th Sep 2003 19:47
So let me put these things together, just a very small demo.
Rem create character
gosub_create_character

Rem create world
gosub_create_world

Rem control character
gosub_create_character.
Would i put the code

In the _create_character

Rem control enemies
gosub_create_enemies

Would i place the enemies health, and die in the _create_enemies as well as the movements?

Rem load game
_load_game:
Place BSP worlds, objects, sky objects in here

Rem Load models for enemies
Put enemies objects, movements such as idle, die in here.

Rem load sound
Load all sound in here depending on what it's for like Gunsnd=1

Rem load music
Put music files for background etc in here

Rem load images
Well if there is any that i need

I will also put the objects for the world in as well like _make_world and place the X,Y,Z in

What i have shown you is just a very quick idea, off course not everything isn't in it yet, but i will get the hang of it studying.
Could you tell me if this is a sort of like correct thing I am doing?
David T
Retired Moderator
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 14th Sep 2003 19:55 Edited at: 14th Sep 2003 19:56
Quote: "


Would i put the code In the _create_character?"


I'm afraid you've lost me with all that, but I can answer the above question. No. That code is just some from the alienware demo which will play a certain animation depedning on what key if pressed.

Here's how I would structure it:



c:/dos
c:/dos run
run dos run
Mentor
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 14th Sep 2003 20:03
Rem create character
gosub_create_character

gosub create_enemies

Rem create world
gosub_create_world

Rem Load models for enemies
Put enemies objects, movements such as idle, die in here.

Rem load sound
Load all sound in here depending on what it's for like Gunsnd=1

Rem load music
Put music files for background etc in here

Rem load images


Rem load game
_load_game:
Place BSP worlds, objects, sky objects in here

do:rem start of loop

Rem control character
rem Numerics for Animations
k$=lower$(inkey$())
if k$="a" then loop object 1,0,100 : desc$="IDLE"
if k$="b" then loop object 1,100,150 : desc$="IMPACT"
if k$="c" then loop object 1,150,200 : desc$="ATTACK 1"
if k$="d" then loop object 1,200,250 : desc$="FALL DOWN"
if k$="e" then loop object 1,250,300 : desc$="GET UP"
if k$="f" then loop object 1,300,350 : desc$="ATTACK 2"
if k$="g" then loop object 1,350,400 : desc$="DUCK"
if k$="h" then loop object 1,400,500 : desc$="DANCE"
if k$="i" then loop object 1,500,550 : desc$="JUMP 1"
if k$="j" then loop object 1,550,650 : desc$="JUMP 2"
if k$="k" then loop object 1,670,720 : set object frame 1,650 : desc$="WALK"
gosub check_for_collisions

In the _create_character

Rem control enemies
gosub_control _enemies

sync
loop

you seem to be getting a little ahead of yourself, it would realy help you if you tried a tutorial or two so that you get the idea of how variables and loading objects works, then you will know in what order to start your game, I strongly suggest you try at least two tutorials, cheers.

Mentor.
Andrew
22
Years of Service
User Offline
Joined: 23rd Aug 2003
Location: United Kindom (what makes it important?)
Posted: 14th Sep 2003 20:05
I understand why you dont understand what i mean by the code, dont worry about that bit, i do understand what you are getting at though.
The code you gave me, is that to:
Load the player
Load the enemy
Player attacks enemy and takes health down

What about the enemy taking the players healt down.

My code that i gave is to load the world, make the character, Make the character move, make an enemy, make an emey move.
Plus hold on a min...The code

Where would i store this then? dont foget it's to make the character attack, jump, etc
Andrew
22
Years of Service
User Offline
Joined: 23rd Aug 2003
Location: United Kindom (what makes it important?)
Posted: 14th Sep 2003 20:07
I have study the tutories, but they dont give out some information that i need, by getting a little help makes me understand and read up on the words better.
But Mentor do you think that the code i gave out is correct?
David T
Retired Moderator
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 14th Sep 2003 20:27 Edited at: 14th Sep 2003 21:20
What about the enemy taking the players healt down.

I won't answer that question. Reverse the code that makes the play take down the enemy's health.


Quote: "Plus hold on a min...The code


Where would i store this then? dont foget it's to make the character attack, jump, etc "


You won't "store" that exact code anywhere as that was just an example, to show you how to play certain frames on animation. It is of little or no use in your game.

c:/dos
c:/dos run
run dos run
Andrew
22
Years of Service
User Offline
Joined: 23rd Aug 2003
Location: United Kindom (what makes it important?)
Posted: 14th Sep 2003 20:37
So if i wanted a character to jump, and i wanted it to press a
What sort of code would i use
Where would i place it?
Mentor
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 14th Sep 2003 21:17 Edited at: 14th Sep 2003 21:19
a lot of these questions are the sort you would not ask if you knew even the smallest amount of basic, you realy need to slow down, before you try to make the next Return to Castle Wolfenstien you NEED to understand the basics, theres a good reason that big games take years to write, and thats because even with something like Darkbasic there is a lot you have to do to make a game work, you can make any game you like, as complicated as you like, but with all this power comes a kind of initiation, that is that you have to learn the basics of programing, you can`t just take bits of code and paste them into the editor to make a game, every section of code is specific to the game or application it was made for, you have to learn to code your own program, you can never make anything by just adding snippets together, PLEASE try one of the simpler tutorials, read the manual and try a few experiements, ask for advice, start with something way simpler than a full blown first person slash em up, read up on text commands and try to get your name on the screen, then try to give the program the ability to ask for your name and print it, go on from there and learn what the commands do, read the manual and ask on here, at the moment the only way you will get a working program is if somebody writes one for you, slow down, forget Quake XP+, start from simple examples and work up, in two weeks you will be able to do some basic 3d, then you can build on that, cheers.

Mentor.
David T
Retired Moderator
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 14th Sep 2003 21:19
Quote: "What sort of code would i use"


I won't give you the commands (leave that to you and the help file ) but here is the basic structure:



then you would have some gravity code somewhere in the loop that would gradually move the char down.

Personally i'd ignore jumping for now - it's quite hard to do and if you can't grasp basic concepts then you've no hope with it i couldn't understand it for a while.


Quote: "Where would i place it? "


I the main loop, where all controls code goes

c:/dos
c:/dos run
run dos run
Andrew
22
Years of Service
User Offline
Joined: 23rd Aug 2003
Location: United Kindom (what makes it important?)
Posted: 14th Sep 2003 21:20
Will do--THANKS

Login to post a reply

Server time is: 2026-07-23 15:48:34
Your offset time is: 2026-07-23 15:48:34