// game function:
void main(){
// load an empty level:
level_load("");
// make sky WHITE:
vec_set(sky_color.blue, COLOR_WHITE);
// no sun_light:
sun_light = 0;
// rotate camera downwards:
vec_set(camera.pan, vector(0, -90, 0));
// enable mouse:
mouse_mode = 4;
// create empty panel:
PANEL* spaceShip = pan_create("", 1);
// make it visible:
set(spaceShip, SHOW);
// create black bmap for it:
spaceShip.bmap = bmap_createblack(16, 32, 24);
// update panels size:
spaceShip.size_x = bmap_width(spaceShip.bmap);
spaceShip.size_y = bmap_height(spaceShip.bmap);
// set rotation center for the panel (right in the middle):
spaceShip.center_x = spaceShip.size_x * 0.5;
spaceShip.center_y = spaceShip.size_y * 0.5;
// create cube model:
you = ent_create(CUBE_MDL, vector(0, 0, -50), NULL);
// set it's size:
vec_set(you.scale_x, vector(0.5, 0.25, 0.5));
// make it change it's color:
set(you, LIGHT);
// make it's color GREEN:
vec_set(you.blue, COLOR_GREEN);
// temporary vector:
VECTOR tempVec;
// set all vector members to zero:
vec_fill(tempVec.x, 0);
// loop:
while(!key_esc){
// save mouse positions (XY):
tempVec.x = mouse_pos.x;
tempVec.y = mouse_pos.y;
// save cube's Z position (not really needed):
tempVec.z = you.z;
// convert vector from screen coordinates into the world!
vec_for_screen(tempVec.x, camera);
// subtract cube's position (so we'll have a direction to rotate at):
vec_sub(tempVec.x, you.x);
// rotate cube towards the direction we've calculated above:
vec_to_angle(you.pan, tempVec.x);
// cycle cube's PAN angle from 0 to 360:
you.pan %= 360;
// don't allow to change it's TILT and ROLL angles:
you.tilt = you.roll = 0;
// place panel right in the middle of the screen:
spaceShip.pos_x = (screen_size.x / 2) - (bmap_width(spaceShip.bmap) / 2);
spaceShip.pos_y = (screen_size.y / 2) - (bmap_height(spaceShip.bmap) / 2);
// set it's pan to the cube's pan:
spaceShip.angle = you.pan;
// cycle panel's pan from 0 to 360:
spaceShip.angle %= 360;
// show panel's angle on screen:
DEBUG_VAR(spaceShip.angle, 10);
// show cube's PAN angle on screen:
DEBUG_VAR(you.pan, 40);
// show current mouse position as a red quad:
draw_quad(NULL, vector(mouse_pos.x, mouse_pos.y, 0), NULL, vector(16, 16, 0), NULL, COLOR_RED, 100, 0);
// wait one frame:
wait(1);
}
// exit application:
sys_exit("bye!");
}