Help with problem on keyboard input

Started by
19 comments, last by Watever 16 years ago
"does it work?" is the question =)
Advertisement
no...i still cant see the enemy or the player....

[Edited by - Watever on April 2, 2008 8:39:26 PM]
ok ok i fixed it!!!! it turns out that since i put glDisable(GL_DEPTH) for drawLevel1 i had to make the depth negative for the player and the enemy to make it visible!!!

all i need now is to know how to update AI

[Edited by - Watever on April 2, 2008 9:38:25 PM]
You maybe should think about think about changing the objects position floats to a vector3 instead, it's easier and you get alot of the math function build in

Quote:
void UpdateAI()    for every AI        if curAI distance from player < 20            shoot at player        elseif curAI distance from player < 100            move curAI towards player
ok ok if vector3 how is vector3 good for math and for what math functions is it good for???
or what if i use glOrtho and switch all the positions to int..would that work too? for int is very easy...
glOrtho is a Orthographic projection matrix, this is not what you are looking !

Vector:
http://en.wikipedia.org/wiki/Vector_%28spatial%29
WAY TO COMPLICATED im only 13....im not in triginometry or algebra2!!!! or whatever that is!!! anything else?
a vector3 is x,y,z in a single object, it's mostly represented as a direction, but doesn't have to be.

if you have your players' position vector and the enemy position vector you can subtract them from each other and get the length of that vector.

vector3 player_pos;
vector3 enemy_pos;
vector3 vec = player_pos - enemy_pos;

float distance_from_each_other = vector3length( vec );


this is the same as:


float p_x, p_y, p_z;
float e_x, e_y, e_z;
float new_x = p_x - e_x;
float new_y = p_y - e_y;
float new_z = p_z - e_z;

// Pythagoras' theorem
float distance = sqrt( new_x*new_x + new_y*new_y + new_z*new_z );
well that seems like less code.......
ok ok....i get it...i will post if i get any problems

This topic is closed to new replies.

Advertisement