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.

Dark GDK / Line of Sight

Author
Message
haliop
User Banned
Posted: 6th Dec 2009 15:31
hello , a long dream of mine is the create a simple Top Down / Isometric shooter, for now i'll try the Top Down shooter.

i dont know a lot on programming , but i do try my best
in the bitmap below , is an example of how the Ling of Sight works in my head ,, the only problem is , that i do not know how to code it





how to do it?
Ultimate_H
15
Years of Service
User Offline
Joined: 11th Mar 2009
Location: A place that is neither here nor there
Posted: 6th Dec 2009 20:03
If you are thinking of making this game in 3d(uses 3d models for the top-down view), I would suggest looking into something called Ray casting. The basic idea is that a line comes from one point and moves to another, and stops at the first thing it hits, or at the end. A good library to look into is Sparky's collision. It's faster than GDK's built in collision commands, and has some more things you can do with it(including ray casting).

if you are thinking of doing it in 2d, then you could use an invisible sprite(like a 1x1 with the color being the transparent color) and move it along a line in each direction and stop on the first thing it hits, though this may be slow.

Hope that helps
-H

heyufool1
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location: My quiet place
Posted: 6th Dec 2009 20:13 Edited at: 6th Dec 2009 20:17
What I would do something like:

1. Check distance between player and enemy.
If the player is close enough:
2. Compare the angles of the enemy and the player to check if the enemy is facing in the general direction of the player.
3. Do a raycast or some kind of line collision between the player and the enemy.
4. If there was a collision then the player is hidden.
4. If there was not a collision then the player is in sight.

Your bedtime story is scaring everyone
If found my very own Fail!: http://cheezburger.com/View.aspx?aid=2712171776

Login to post a reply

Server time is: 2024-10-01 18:22:27
Your offset time is: 2024-10-01 18:22:27