Advertisement
Advertisement
| 05.19.2008 at 08:50AM PDT, ID: 23414104 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
|
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: |
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <stdio.h>
//include the engine data types, variables, and functions
#include "adll.h"
#include "init_engine.h"
#include "grid.h"
ENTITY* gStartEnt = NULL; //pointer to start entity
ENTITY* gGoalEnt = NULL; //pointer to goal entity
int gStartNode = -1; //start node, initialized to -1
int gGoalNode = -1; //goal node, initialized to -1
//draw path from goal position to goal node, then along all connections back to start node, then to start position
void draw_path()
{
COLOR cColour; //colour vector
VECTOR vTemp; //temp vector
//set the colour to light grey
cColour.blue = _VAR(0);
cColour.green = _VAR(255);
cColour.red = _VAR(255);
//set temp vector to goal position
vTemp.x = gGoalEnt->x;
vTemp.y = gGoalEnt->y;
vTemp.z = _VAR(30);
//place the draw position there, (pass colour as NULL because don't want to start drawing yet)
draw_line3d(&vTemp, NULL, _VAR(100));
//set it to the correct colour
draw_line3d(&vTemp, &cColour, _VAR(100));
//set temp vector to goal position
vTemp.x = gStartEnt->x;
vTemp.y = gStartEnt->y;
vTemp.z = _VAR(30);
draw_line3d(&vTemp, &cColour, _VAR(100));
}
//this function handles left mouse clicks
void handle_leftclick()
{
VECTOR position; //temp position variable
int i, closest_node; //for loop counter and variable for closest node found so far
float closest_distance, temp_distance; //variables for closest distance found so far and temp distance
//if there is no start node
if(gStartNode == -1)
{
if(get_position(&position, gStartNode)) //if mouse clicked on valid position
{
gStartEnt = ent_create("blue_target.mdl", &position, NULL); //create entity at start position
}
}
//if there is no goal node
else if(gGoalNode == -1)
{
if(get_position(&position, gGoalNode)) //if mouse clicked on valid position
{
gGoalEnt = ent_create("target.mdl", &position, NULL); //create entity at goal position
draw_path();
/////////////////////////////////////////////////////////////////////////////////////////////////////
//CALL YOUR PATH FINDING FUNCTION HERE
/////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
else //reset
{
if(gStartEnt != NULL) //check whether there is a start entity (just in case)
{
ent_remove(gStartEnt); //remove entity
gStartEnt = NULL; //reset pointer to NULL
}
if(gGoalEnt != NULL) //check whether there is a goal entity (just in case)
{
ent_remove(gGoalEnt); //remove entity
gGoalEnt = NULL; //reset pointer to NULL
}
gStartNode = -1; //reset start node
gGoalNode = -1; //reset goal node
reset_node_records(); //reset node records
}
}
//main function
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
engine_init(); //calls function that initializes the engine
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//initialise everything you need before entering main rendering loop
init_grid(); //setup the grid
reset_node_records(); //initialize the node records
//assign function for left mouse click
v(on_mouse_left) = (EVENT)handle_leftclick;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//main rendering loop, this will loop once every frame until you quit
while(engine_frame())
{
//update debug text display
update_debug_text();
}
//DO NOT CHANGE
engine_close(); //engine frees all created entities, bitmaps and sounds automatically when closing
return 0;
}
|