История изменений
Исправление amaora, (текущая версия) :
struct life_t ball_life {
.update = ball_update,
}
struct life_t camera_life {
.init = camera_init,
.update = camera_update,
}
void ball_update(element_t *el)
{
struct input_t *in = &global_input;
vec3_t f;
if (in->key[KEY_LEFT]) {
vec3(f, 0, 1, 0);
phys_apply_force(el->phys, f);
}
if (in->key[KEY_UP]) {
/* TODO */
}
mat44_cpy(el->visual->m, el->phys->m);
}
void camera_init(element_t *el)
{
element_t *target;
/* TODO: get target link */
element_insert_link(el, target, "target");
/* TODO: initialize view matrix */
}
void camera_update(element_t *el)
{
element_t *target;
mat44_t mo;
vec3_t v;
target = element_get_link_by_tag(el, "target");
v = vec3_sub(target->phys->pos, el->phys->pos);
/* TODO: calculate mo */
render_set_view_matrix(render, mo);
}
void ball_scene_startup()
{
element_t *el;
phys_obj_t *po;
element_life_register("ball", ball_life);
element_life_register("camera", camera_life);
/* FIXME: to load map instead */
scene_unlink_all();
el = element_construct("/res/obj/ball");
scene_attach(el);
el = element_construct_bare("camera");
po = phys_construct_minimal();
el->phys = po;
scene_attach(el);
}
Исправление amaora, :
struct life_t ball_life {
.update = ball_update,
}
struct life_t camera_life {
.init = camera_init,
.update = camera_update,
}
void ball_update(element_t *el)
{
struct input_t *in = &global_input;
vec3_t f;
if (in->key[KEY_LEFT]) {
vec3(f, 0, 1, 0);
phys_apply_force(el->phys, f);
}
if (in->key[KEY_UP]) {
/* TODO */
}
mat44_cpy(el->visual->m, el->phys->m);
}
void camera_init(element_t *el)
{
element_t *target;
/* TODO: get target link */
element_insert_link(el, target, "target");
/* TODO: initialize view matrix */
}
void camera_update(element_t *el)
{
element_t *target;
mat44_t mo;
vec3_t v;
target = element_get_link_by_tag(el, "target");
v = vec3_sub(target->phys->pos, el->phys->pos);
/* TODO: calculate mo */
render_set_view_matrix(render, mo);
}
void ball_scene_startup()
{
element_t *el;
phys_obj_t *po;
element_life_register("ball", ball_life);
element_life_register("camera", camera_life);
/* FIXME: to load map instead */
scene_unlink_all();
el = element_construct("/res/obj/ball");
scene_attach(el);
el = element_construct_bare("camera");
po = phys_construct_minimal();
el->phys = po;
scene_attach(el);
}
Исправление amaora, :
struct life_t ball_life {
.update = ball_update,
}
struct life_t camera_life {
.init = camera_init,
.update = camera_update,
}
void ball_update(element_t *el)
{
struct input_t *in = &global_input;
vec3_t f;
if (in->key[KEY_LEFT]) {
vec3(f, 0, 1, 0);
phys_apply_force(el->phys, f);
}
if (in->key[KEY_UP]) {
/* TODO */
}
mat44_cpy(el->visual->m, el->phys->m);
}
void camera_init(element_t *el)
{
element_t *target;
/* TODO: get target link */
element_insert_link(el, target, "target");
/* TODO: initialize view matrix */
}
void camera_update(element_t *el)
{
element_t *target;
mat44_t mo;
vec3_t v;
target = element_get_link_by_tag(el, "target");
v = vec3_sub(target->phys->pos, el->phys->pos);
/* TODO: calculate mo */
render_set_view_matrix(render, mo);
}
void ball_scene_startup()
{
element_t *el;
element_life_register("ball", ball_life);
element_life_register("camera", camera_life);
/* FIXME: to load map instead */
scene_unlink_all();
el = element_construct("/res/obj/ball");
scene_attach(el);
el = element_construct_bare("camera");
po = phys_construct_minimal();
el->phys = po;
scene_attach(el);
}
Исходная версия amaora, :
struct life_t ball_life {
.update = ball_update,
}
struct life_t camera_life {
.init = camera_init,
.update = camera_update,
}
void ball_update(element_t *el)
{
struct input_t *in = &global_input;
vec3_t f;
if (in->key[KEY_LEFT]) {
vec3(f, 0, 1, 0);
phys_apply_force(el->phys, f);
}
if (in->key[KEY_UP]) {
/* TODO */
}
mat44_cpy(el->visual->m, el->phys->m);
}
void camera_init(element_t *el)
{
element_t *target;
/* TODO: get target link */
element_insert_link(el, target, "target");
/* TODO: initialize view matrix */
}
void camera_update(element_t *el)
{
element_t *target;
mat44_t mo;
vec3_t v;
target = element_get_link_by_tag(el, "target");
v = vec3_sub(target->phys->pos, el->phys->pos);
/* TODO: calculate mo */
render_set_view_matrix(render, mo);
}
void ball_scene_startup()
{
element_t *el;
element_life_register("ball", ball_life);
element_life_register("camera", camera_life);
/* FIXME: to load map instead */
scene_unlink_all();
el = element_construct("/res/obj/ball");
scene_attach(el);
el = element_construct_bare("camera");
scene_attach(el);
}