//include <default.fx>;
//include <mtlFX.wdl>;
//include <default.fx>;
//include <mtlFX.wdl>;
#include <acknex.h>
#include <default.c>
#include "mtlFX.c"
#define PRAGMA_PATH "%EXE_DIR%\code";
#define PRAGMA_PATH "images";
#define PRAGMA_PATH "terrains";
#define PRAGMA_PATH "levels";
#define PRAGMA_PATH "models";
////////////////////////////////////////////////////////////////////
#define xmax 1680
#define ymax 1050
#define fscreen 1
BMAP* nneglogo = "nnegamingLOGO.bmp";
BMAP* dhlogo = "dementia_hillsLOGO.bmp";
BMAP* dhmenustart = "dhmenustart.bmp";
BMAP* dhmenustartover = "dhmenustart_over.bmp";
BMAP* mcursor = "brokenarrow.pcx";
var camh;
var distx,disty,distz,distxy;
var tempforcex,tempforcey;
var tempforcex2,tempforcey2;
ENTITY* skycube;
PANEL* splash1 = {
pos_x=0;
pos_y=0;
layer=2;
bmap = nneglogo;
flags = VISIBLE;
}
PANEL* splash2 = {
pos_x=0;
pos_y=0;
layer=1;
bmap = dhlogo;
flags = VISIBLE;
}
PANEL* mainmenu = {
pos_x=0;
pos_y=350;
layer=3;
button(0,0,dhmenustart,dhmenustart,dhmenustartover,startworld,NULL,NULL);
flags = OVERLAY;
}
PANEL* deb = {
pos_x = 200;
pos_y = 300;
digits(0,0,"CamHeight: %.1f",*,1,camh);
digits(0,12,"Camera.Tilt: %.1f",*,1,camera.tilt);
digits(0,24,"Mouse Force X: %.1f",*,1,mouse_force.x);
digits(0,36,"Mouse Force y: %.1f",*,1,mouse_force.y);
digits(0,48,"Distance X : %.1f",*,1,distx);
digits(0,60,"Distance Y : %.1f",*,1,disty);
digits(0,72,"Distance Z : %.1f",*,1,distz);
digits(0,84,"Distance XY : %.1f",*,1,distxy);
digits(0,96,"TempForce X : %.1f",*,1,tempforcex);
digits(0,108,"TempForce Y : %.1f",*,1,tempforcey);
digits(0,120,"Player.Pan : %.1f",*,1,player.pan);
digits(0,132,"Player.Tilt : %.1f",*,1,player.tilt);
digits(0,144,"Camera.Arc : %.1f",*,1,camera.arc);
flags = OVERLAY | VISIBLE;
}
function startworld(){
//Start Loading Shit
camera.arc = 30; //Zoom Factor
while(player == NULL) { wait(1); }
vec_set(camera.x,vector(-180,0,70));
vec_rotate(camera.x,player.pan);
vec_add(camera.x,player.x);
camera.pan = player.pan;
camera.tilt = -10;
distx = player.x - camera.x;
disty = player.y - camera.y;
distz = player.z - camera.z;
toggle(mainmenu,VISIBLE);
toggle(splash1,VISIBLE);
toggle(splash2,VISIBLE);
mouse_mode=1;
}
action players_code() {
tempforcex = 1;tempforcey = 1;
var anim_percentage; // animation percentage
VECTOR movement_speed; // player's movement speed
VECTOR tempcamera;
var distance_to_ground; // the distance between player's origin and the ground
var camdist = 230;
var camheight = 145;
VECTOR temp;
VECTOR temp2;
player = my; // I'm the player
while (1) {
//Calculate Mouse Control
if ( mouse_left ) {
if (mouse_force.x != 0 && !mouse_right) {
tempforcex+=mouse_force.x * 9 * time_step;
}
if (mouse_force.y != 0) {
tempforcey+=mouse_force.y * 6 * time_step;
}
}
if ( mouse_right ) {
my.pan -= 6 * (mouse_force.x) * time_step; // rotate the player
}
//depending upon mouse force change cam offset
if (abs(tempforcex) >= 0 && abs(tempforcex) < 90) {
camera.x=player.x - camdist * cos(player.pan + tempforcex);
camera.y=player.y - camdist * sin(player.pan + tempforcex);
} else if ( abs(tempforcex) > 90 && abs(tempforcex) < 180) {
camera.x=player.x - camdist * -cos(180-(player.pan + tempforcex));
camera.y=player.y - camdist * sin(180-(player.pan + tempforcex));
} else if ( abs(tempforcex) > 180 && abs(tempforcex) < 270) {
camera.x=player.x - camdist * -cos(180-(player.pan + tempforcex));
camera.y=player.y - camdist * sin(180-(player.pan + tempforcex));
} else if (abs(tempforcex) > 270 && abs(tempforcex) < 360) {
camera.x=player.x - camdist * cos(player.pan + tempforcex);
camera.y=player.y - camdist * sin(player.pan + tempforcex);
} else if ( tempforcex < -360 ) {
tempforcex = tempforcex + 360;
} else if ( tempforcex > 360 ) {
tempforcex = tempforcex - 360;
}
if (tempforcey < 0 && tempforcey > -90) {
camera.z=player.z - camheight * sin(player.tilt + tempforcey);
} else if (tempforcey > 0 && tempforcey < 90) {
camera.z=player.z - camheight * sin(180 - (player.tilt + tempforcey));
} else if ( tempforcey >= 90 ) {
tempforcey = 89;
} else if ( tempforcey <= -90 ) {
tempforcey = -89;
}
if (!mouse_left) {
if (tempforcex < 1) {
tempforcex++;
} else if (tempforcex > 1) {
tempforcex--;
}
if (tempforcey < -22) {
tempforcey++;
} else if (tempforcey > -22) {
tempforcey--;
}
if (abs(tempforcex) > 0 && abs(tempforcex) < 1){
tempforcex=0;
}
if (tempforcey > -22 && tempforcey < -21){
tempforcey=-22;
}
if (tempforcey < -22 && tempforcey > -23 ){
tempforcey=-22;
}
}
camh = camheight;
//LOOK AT PLAYER
vec_set(temp2.x,player.x);
temp2.z+=20;
vec_sub(temp2.x,camera.x);
vec_to_angle(camera.pan,temp2);
camera.arc+=mickey.z * 0.01;
my.pan += 6 * (key_a - key_d) * time_step; // rotate the player using the "A" and "D" keys
vec_set (temp.x, my.x); // copy player's position to temp
temp.z -= 5000; // set temp.z 5000 quants below player's origin
distance_to_ground = c_trace (my.x, temp.x, IGNORE_ME | USE_BOX);
if ( mouse_left && mouse_right ){
movement_speed.x = 10 * 1 * time_step; // move the player using "W" and "S"
} else {
movement_speed.x = 10 * (key_w - key_s) * time_step; // move the player using "W" and "S"
}
movement_speed.y = 0; // don't move sideways
movement_speed.z = - (distance_to_ground - 20); // 17 = experimental value
movement_speed.z = maxv(-35 * time_step, movement_speed.z); // 35 = falling speed
c_move (my, movement_speed.x, nullvector, GLIDE); // move the player
if ((key_w == OFF) && (key_s == OFF)) {
if(mouse_left && mouse_right){
ent_animate(my, "Walka", anim_percentage, ANM_CYCLE); // play the "walk" animation
} else {
ent_animate(my, "Standa", anim_percentage, ANM_CYCLE); // play the "stand" animation
}
} else {
ent_animate(my, "Walka", anim_percentage, ANM_CYCLE); // play the "walk" animation
}
anim_percentage += 8 * time_step; // 5 = animation speed
wait (1);
}
}
function main()
{
video_set(xmax,ymax,32,fscreen);
screen_color.blue=0;
screen_color.red=0;
screen_color.green=0;
splash1.size_x = xmax;
splash1.size_y = ymax;
var xm = (int)xmax;
var ym = (int)ymax;
splash1.scale_x = xm / 1024;
splash1.scale_y = ym / 768;
splash2.size_x = xmax;
splash2.size_y = ymax;
splash2.scale_x = xm / 1024;
splash2.scale_y = ym / 768;
//wait(2);
//wait(-8);
splash1.bmap=dhlogo;
while(splash1.pos_x <= 125) {
splash1.pos_x += 3 * time_step;
//wait(1);
}
toggle(mainmenu,VISIBLE);
level_load("dh.wmb");
skycube = ent_createlayer("Sky_2+6.tga", SKY | CUBE | VISIBLE, 0);
mouse_map= mcursor;
mouse_mode = 2;
//delay the inevitable
while(key_pressed(key_for_str("q")) == 0) {
//Process Mouse
mouse_pos.x = mouse_cursor.x;
mouse_pos.y = mouse_cursor.y;
if (player != NULL) {
}
//next cycle
wait(1);
}
sys_exit("p00!");
}