1 registered members (TipmyPip),
18,388
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
A few beginners problems
#348801
11/30/10 19:58
11/30/10 19:58
|
Joined: Nov 2010
Posts: 7 Sweden
jakk_zeven
OP
Newbie
|
OP
Newbie
Joined: Nov 2010
Posts: 7
Sweden
|
I just started to learn Lite-C and began with the workshop. After almost going through everything I decided to use the car model and create a little racing game to get things started. I realise that it may not be the best starting point, but it shouldnt be to hard. But I have run into some problems with my code.
Im trying to make the car drop a bomb by pressing ctrl, but instead of one it creates a whole trail of bombs.
Also Im working on getting a sprite to work as a boostpad but that is not going to well either.
Im not looking for anyone to give me code, that wouldnt help learning at all. Im just looking for some pointers to what commands and so on I should look into.
Keep in mind that Im just starting out with this so the code is probably kind of messy. But here it is(the code looks slightly different here but that should just be the indentation):
racing.c /////////////////////////////// #include <acknex.h> #include <default.c> #include "weapons.c" #include "player.c" #include "panels.c" #include "functions.c" ///////////////////////////////
function main() { video_mode=7; fps_max=60; mouse_mode = 4; //level_load ("racing.wmb");
wait (2);
} //////////////////////////////////////////
weapons.c
function bomb_drop(x,y,z,nrofbombs) { if (nrofbombs==1) ent_create("bomb.mdl",vector(x,y,z),NULL); return(nrofbombs=0);
}
///////////////////////////////////////////
player.c
//Car definitions and variables ENTITY* car;
var acc = 0.5; var speed = 0; var boost = 0;
//Weapon definitions var nrofbombs = 1;
//Topview follow cam function update_camera() { while(1) { vec_set(camera.x,vector(car.x,car.y,1000)); camera.tilt=-90; wait(1); } }
//playercontrolled car action my_car() { car = me; my.ambient = 0; while (1) { // move the car using relative_speed if (key_cul) my.pan += 4*time_step; // increase the pan angle of the car if (key_cur) my.pan -= 4*time_step; // decrease the pan angle of the car if (key_cuu ) // press and hold the "Space" key to move the car speed += acc*time_step; c_move (my, vector(speed*time_step, 0, 0), nullvector, USE_POLYGON | IGNORE_PASSENTS); if (speed >= 50) speed = 50; if (!key_cuu ) speed -= 0.2*time_step; if (speed <= 0) speed = 0; if (key_cud) speed -= 0.5*time_step; if (key_ctrl) bomb_drop(my.x,my.y,10,nrofbombs); update_camera(); wait (1); } }
//////////////////////////////////////////////////////////
panels.c
//Main menu
PANEL* main_menu = { //mouse_mode = 4; pos_x = 400; pos_y = 300; button(0,0,"start_pressed.jpg","start.jpg","start.jpg",open_level,NULL,NULL); flags = SHOW | OVERLAY; }
///////////////////////////////////////////////////////////
functions.c
action boostplate() { ENTITY* boostaction; boostaction = my; if ((vector(car.x,car.y,0)) == (vector(my.x,my.y,0))) { var x; x=0; while (x < 100) { speed = 80; x+=1; wait(1); if (x==100) { boost=0; } } } }
function open_level() { reset(main_menu,SHOW); mouse_mode=0; //doesn't work level_load("racing.wmb"); wait(1); }
|
|
|
|