|
function moveCamera() {
#461967
08/31/16 15:04
08/31/16 15:04
|
Joined: Aug 2016
Posts: 5
NiceOneX
OP
Newbie
|
OP
Newbie
Joined: Aug 2016
Posts: 5
|
Hey guys , I'm new here in the forum and would like to learn how to programiert games. I bought a book that something helps me. However, I have the same at the beginning a problem with my script ... Although the level loads but the function with the camera can not be performed. I thank you in advance for the help. and sorry for my bad english Script:
#include <acknex.h>
#include <default.c>
#define WALK_SPEED 5
function moveCamera() {
VECTOR* vecNewAngle = NULL;
VECTOR* vecNewPosition = NULL;
while(1) {
vecNewAngle = vector(
(camera.pan+(key_a-key_d)*time_step*WALK_SPEED)%360,
0,
0
);
vec_set(camera.pan,vecNewAngle);
vecNewPosition = vector(
camera.x+(key_w-key_s)*cosv(camera.pan)*time_step*WALK_SPEED,
camera.y+(key_w-key_s)*sinv(camera.pan)*time_step*WALK_SPEED,
0
);
vec_set(camera.x, vecNewPosition);
wait(1);
}
}
function main() {
level_load("terrain1.hmp");
VECTOR* vecPosition = vector(0,0,0);
ent_create("world1.mdl",vecPosition,NULL);
moveCamera();
}
Last edited by NiceOneX; 08/31/16 15:50.
|
|
|
Re: function moveCamera() {
[Re: NiceOneX]
#461968
08/31/16 15:26
08/31/16 15:26
|
Joined: Jul 2008
Posts: 2,107 Germany
rayp
X
|
X
Joined: Jul 2008
Posts: 2,107
Germany
|
Hi and welcome on board. The code itself seams to be ok ( i mean it runs without errors ) Create a Terrain (HMP) and a model file (MDL). Both with MED. Then your script will run. Pretty sure it cant load one of those files. Or create a simple map (WMB) with WED. And modify your main function like this
function main() {
level_load("yourlevel.wmb");
moveCamera();
}
Guess problem now is your script / game cant found those files loaded from here
level_load("terrain1.hmp");
ent_create("world.mdl",vecPosition,NULL);
edit: If you write your code here in the forum between [ c o d e ] and [ / c o d e ] but without the empty spaces your text will appear in a codebox and will be much more easy to read edit2: I made another very simple example. Create a map with WED. For example just a hollowed block. Save it as "yourlevel.wmp". Build the map ( will create the WMB file ). Create a new script file with the following code
#include <acknex.h>
#include <default.c>
#define WALK_SPEED skill1 // mask skill1 of ent with WALK_SPEED
#define HEALTH skill2 // same here but with health and skill2
action simpleHero(){ // actions will apear in the WED action list of your script
my.WALK_SPEED = 6; // set our speed
my.HEALTH = 100; // 100 lifepoints
VECTOR dist; // a vector for distance ent is moving
while (my.HEALTH > 0){ // as long as weve lifepoints were looping the code below
dist.x = ((key_w - key_s) * my.WALK_SPEED) * time_step; // forward backward moving
dist.y = ((key_a - key_d) * my.WALK_SPEED) * time_step; // side moving
move_mode = IGNORE_ME | IGNORE_PASSABLE | GLIDE; // used from c_move below
c_move (me, vector (dist.x, dist.y, 0), nullvector, move_mode); // finally move the ent!
my.pan -= mickey.x * time_step; // handle PAN of entity ( left - right looking )
vec_set (camera.x, my.x); // set camera XYZ to entitys XYZ (follow)
camera.pan = my.pan; // set camera PAN to ent pan
camera.roll = 0;
camera.tilt -= mickey.y * time_step; // handle camera TILT ( up - down looking )
camera.tilt = clamp (camera.tilt, -85, 85); // clamp the camera TILT value
wait (1); // wait one frame
}
}
void main() {
level_load("yourlevel.wmb"); // load the level created in WED
ent_create("player.mdl", vector (0,0,0), simpleHero); // load your hero / player
// needs two files in the folder: yourlevel.wmb and your player entity player.mdl
}
Greets
Acknex umgibt uns...zwischen Dir, mir, dem Stein dort... "Hey Griswold ... where u gonna put a tree that big ?" 1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected rayp.flags |= UNTOUCHABLE;
|
|
|
Re: function moveCamera() {
[Re: rayp]
#462003
09/02/16 10:01
09/02/16 10:01
|
Joined: Dec 2011
Posts: 1,823 Netherlands
Reconnoiter
Serious User
|
Serious User
Joined: Dec 2011
Posts: 1,823
Netherlands
|
Hi NiceOneX welcome to do the forum. Since your new; incase you want better shaders (/better graphics) for your game you may want to take a look at 'Shade-C EVO' on this forum or on Github. That is a package that you can include in your script and which gives access to improved hdr, normal mapping, ssao etc. You could basically see it as an upgrade over Gamestudio graphics wise. Here is an usefull thread that you should rease incase you are going to use it and/or get stuck (you can also ask questions there): http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=461868&page=1
|
|
|
|