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 / How to create a simple Line of Sight?

Author
Message
Mokraton
14
Years of Service
User Offline
Joined: 4th Dec 2011
Location:
Posted: 21st Jan 2012 04:22
I am working on a game that is similar to a game of geometry wars, except it features only 1 enemy with ALOT of artificial intelligience.

I'm trying to create a Line Of Sight for my AI so that with my Finite State Machine, I can transition from a hunt mode to an Attack Mode (which I have already coded briefly).

Its a simple game thus far, and a top down view game, so the AI already knows where the player is, but I want to create a simple LOS so he knows when to start shooting (i.e. he will not shoot if there is a wall in his way)

I was thinking of drawing a line between the Enemy and the Player that will loop and constantly update, and create a function to determine if the Line is colliding with any other objects, if it is then the AI will not shoot.

I know how to draw a line with the LINE command, but I cannot figure out what to do next and would highly appreciate anyone's help! I am actively working on this so I will post again if I have come up with the solution and what the solution is.

Also if you know a simpler, and or better way to calculate an AI's LOS then please tell me. Thank You!

Beginning Programmer
Professional Nerd
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 21st Jan 2012 14:00
@Mokraton

Take a look to intersect object command.



Cheers.

I'm not a grumpy grandpa
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 22nd Jan 2012 13:08
This is the same as chafari's code, only it uses sparky's (faster):



TheComet

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 22nd Jan 2012 13:49
Quote: "This is the same as chafari's code, only it uses sparky's (faster):"


Yes I know, but I thought that probably he didn't have this plugin yet.


Cheers.

I'm not a grumpy grandpa
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 22nd Jan 2012 17:28
Quote: "Yes I know, but I thought that probably he didn't have this plugin yet."


Ah right. Well in that case he can use intersect object, they both do the same

@ Mokraton - If you don't have sparky's I suggest you obtain it (It's among the most useful plugins ever created, hence the name "sparky's" ) : http://forum.thegamecreators.com/?m=forum_view&t=74762&b=5

TheComet

MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 23rd Jan 2012 08:26 Edited at: 23rd Jan 2012 08:28
Eugh I know I will eventually land on using Sparkys... perhaps for netbooks but I still like the idea of using my GPU to leverage the Physics ^^

They beat me to saying use a raycast ^^ but yeah umm this got me thinking lol

EDIT

Thanks TheComet for the link will finally take a look at this legendary plugin

EDIT

Its not been touched since 2009 is it completely functional?

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 23rd Jan 2012 12:51
Quote: "Its not been touched since 2009 is it completely functional?"



Have you ever use Sparky's ?

Cheers.

I'm not a grumpy grandpa
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 23rd Jan 2012 13:10
Thought it would be clear that I have not...

Nope avoided it for time being however DarkDynamix tickles my fancy more... but its made by the same person it seems...

Login to post a reply

Server time is: 2026-07-10 01:06:45
Your offset time is: 2026-07-10 01:06:45