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 Discussion / Having many monsters load

Author
Message
NazguL86
20
Years of Service
User Offline
Joined: 14th Feb 2005
Location:
Posted: 7th Apr 2005 04:30
Hi all, i'm trying to create a little FPS game.
At the moment i followed the first tutorial one the site of DBC, the one called "Monsters Hunt", so, my game is similar to this one.
But i would like to have, many, many monsters
What is the best thing to do ? I don't know if putting, all the code in a cycle could be too heavy to process, or too difficult to do; so the other choice would be to copy and paste the code of movements, loading etc...
if anyone has an exemple, or a tutorial, or just some ideas, please tell me, it would be really helpful !
Thanks
Dr Crazy
21
Years of Service
User Offline
Joined: 13th Apr 2004
Location:
Posted: 7th Apr 2005 05:17 Edited at: 7th Apr 2005 05:22
My advice = start from scratch. I used to be a complete n()()b and didn't understand codes yet kept copying and pasting them. Understand EXACTLY what this code does then start from scratch and base it on the tut.

Cheers,
Nick.
[EDIT] If you find something like for t=1 to X , try increasing X.

Check out Cyber Studios for the RPG: 'The Sacran' and for DBPro and miscellaneous
[href][/href]
Formally known as SAS Elite Pvt Rakosi
Dr Crazy
21
Years of Service
User Offline
Joined: 13th Apr 2004
Location:
Posted: 7th Apr 2005 05:56 Edited at: 7th Apr 2005 05:58
Also perhaps you could snoop around for a fps engine on the codebase :p

Home of the RPG: The Sacran http://www.cstudios.bravehost.com

Used to be Pvt Rakosi
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 7th Apr 2005 17:08
NazguL86,

Copying and pasting will work. However, if you wish to increase your skills, start to at least study what the code, in which you are copying, is doing to create the scene. When writing your own code, you will want to find the shortest route that will solve your problem. After writing a piece of code, go back over it several times, trying to figure a more efficient way to solve the problem.

Remember, that the less calculations needed to run your program, the faster it will run. Also, in this language(DarkBasic), the less code there is, the faster your program will run, also. This is because DarkBasic uses a 'compiler', and has to re-translate your 'source code' each program loop.

Do not get into the habit of 'Hard-Coding', which is usually when a person does not make use of functions and repeatable loops. Instead, he adds to the compiler's job by re-typing the same lines of code throughout his program. Make use of functions.

One last hint. By all means, whenever possible, split your calculations into different program loops. For example, if you are programming a.i. in a First Person Shooter, take the first loop to calculate it's line-of-site, the second to calculate it's movements, the third to calculate it's shooting and so on.

+NanoBrain+
Dr Crazy
21
Years of Service
User Offline
Joined: 13th Apr 2004
Location:
Posted: 7th Apr 2005 19:51
Yeah a good programmer uses lots of functions to save time(like me)

Home of the RPG: The Sacran http://www.cstudios.bravehost.com

Used to be Pvt Rakosi
NazguL86
20
Years of Service
User Offline
Joined: 14th Feb 2005
Location:
Posted: 7th Apr 2005 22:38
well, i think you didn't understood what i wanted to mean.
I would like to know which is the best thing to do, when i want to have many monsters in game. Like, putting the "object load " instruction in a cycle, or, if i know that i just want 3 monsters, i could copy and paste the code needed for each monster, 3 times...
i appreciate your tips, but it would be better to directly see maybe an example of making many monsters in a game, but i didn't find any tutorials about that! I know that the best thing to do would be starting from scratch, but i don't have much time, becouse this game is going to be a project for my exam in my school
HWT
20
Years of Service
User Offline
Joined: 1st Apr 2005
Location: Earth
Posted: 8th Apr 2005 04:10
Hi there

I've made a very rough sketch for you but I think you'll be able to follow it....


Simple Pseudo-Language Script

STEP 1: Load your monster object several times (as many as you need).
STEP 2: Position them randomly using rnd(...)command.
STEP 3: In the loop (as per Monster Hunt tutorials), point the monster towards the player and make him move towards him.
STEP 4: If the distance between [Player] and [Monsters] is less than ... then make the monster carry out [punch animation] and [hurt player].

Here is an analogy of the above in DBC Code:

rem Before the loop, when you're loading the world
`STEP 1: Creating 10 multiple enemies
for i = 1 to 10 : load object "monster.x",i : next i

`STEP 2: Positioning - you can put this in the loop above also
for i = 1 to 10 : position object i,rnd(...),0.0,rnd(...) : next i

`EXTRA STEP: Globalisation of variables; here we make an array to `fit the monster's status
dim monster(10)

rem Inside the loop
`STEP 3: Movement (see STEP 4 if you don't understand why I set this `array here)
for i = 1 to 10
if monster(i)=0
point object i,playerx#,playery#,playerz#
xrotate object i,0 : zrotate object i,0
move object i,5
endif
next i

`STEP 4: AI and attacking (again you can put this in the above loop)
`First we start the loop, then calculate distance using the math
`formula, then check the value of the distance, and then send the
`monster in to attack or continue patrol mode
for i = 1 to 10
dist#=sqrt( (monsterx(i)-playerx)^2 + (monsterz(i)-playerz)^2
if dist#<5.0 then monster(i)=1 else monster(i)=0
if monster(i)=1 then play object i,[attacking animation] : playerhealth = playerhealth-2
next i

NOTE: THIS CODE WON'T JUST WORK BY COPY AND PASTE


I hope this helps in some way. If you don't understand at first, try to go over it again and again, but even after having done so you still can't make sense of it, please don't hesitate to ask because we are here to help

Good Luck! And remember that coding takes time and practice so be patient

HelloWorld Tommorrow
NazguL86
20
Years of Service
User Offline
Joined: 14th Feb 2005
Location:
Posted: 8th Apr 2005 04:22
thank you really much HWT,
now i'm going to understand and try to implement it in my game...
thanks again
HWT
20
Years of Service
User Offline
Joined: 1st Apr 2005
Location: Earth
Posted: 8th Apr 2005 04:32
You're very welcome NazguL86

HelloWorld Tommorrow
waffle
22
Years of Service
User Offline
Joined: 9th Sep 2002
Location: Western USA
Posted: 10th Apr 2005 04:31
check out the "iced" demo.
Its a basic FPS with many monsters and a rapid fire "gun".

There are lots of good tips in there, if you know how to read
lee's code

examples:

monster reflections
smoke effects
mouse look (and other standard FPS control stuff)
basic AI (monsters do more than just attack)
sliding on slippery surface
Loading and saving a level ... (no editor though)
Compass display
Health Display (not active though)
Rain/Snow effect

and my favorite that I still use to help with 2D games ...
How to convert a 3D animated object to a series of
bitmaps that can be used for animated sprites

Login to post a reply

Server time is: 2025-05-23 08:18:25
Your offset time is: 2025-05-23 08:18:25