Skip to content

Commit

Permalink
Clean up code, optimize key model
Browse files Browse the repository at this point in the history
  • Loading branch information
bl0ckeduser committed Dec 2, 2011
1 parent d972f0b commit fd22b65
Show file tree
Hide file tree
Showing 20 changed files with 1,249 additions and 1,327 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# [this is a copy of the libnds all-purpose template Makefile]

#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ implement a reader (string-read.c) because
you don't usually have a filesystem available on NDS.
(i.e. model data is stored directly as text in the game ROM.
the data-source directory contains the low-poly model files,
which are "compiled" to source files [*-mdl.c] via the "data2src"
which are "compiled" to model-data.c via the "data2src"
script/program).

I then copy-pasted libnds 3D example code by Dovoto to
Expand Down
6 changes: 3 additions & 3 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
(small) range. A workaround for this quirk was added to
model-draw.c; use drawModelWithGL_big(model*) to use this
fixed version.

- Faster code / optimize
+ Faster code / optimize
* key model seems to be the [performance] culprit.
will have to decrease vertex count all over again...

- More optimization ?
- Add lighting/shininess/antialiasing/you-name-it effects
to make things nicer

Expand Down
31 changes: 0 additions & 31 deletions bullet-mdl.c

This file was deleted.

18 changes: 3 additions & 15 deletions bullet.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#include "headers.h"
#include <math.h>

#define BULLET_YACCEL -1.0

game_obj* newBullet(game_obj* list, float x, float y, float z, float angle)
{
game_obj* bul = newListNode(list);
Expand Down Expand Up @@ -30,23 +28,13 @@ void bulletTick(game_obj* bul)
deleteNode(bul);
}

/* resulting from a special request,
the bullets have gravity */
/*
stupid idea
if(bul->data[BULLET_YVEL] < BULLET_YACCEL)
bul->data[BULLET_YVEL] = BULLET_YACCEL;
bul->data[BULLET_YVEL] += BULLET_YACCEL * dtime;
movey = bul->data[BULLET_YVEL] * dtime +
(BULLET_YACCEL * dtime * dtime) / 2.0;
*/
#ifdef PC_TARGET
#ifdef PC_TARGET
dirx = (float)sin(bul->data[BULLET_ANGLE] / 360.0 * (2*3.14));
dirz = (float)cos(bul->data[BULLET_ANGLE] / 360.0 * (2*3.14));
#else
#else
dirx = my_sin(bul->data[BULLET_ANGLE]);
dirz = my_cos(bul->data[BULLET_ANGLE]);
#endif
#endif

bul->data[BULLET_X] += 20 * dirx * dtime;
bul->data[BULLET_Y] += movey;
Expand Down
Binary file modified clown3d-DS.elf
Binary file not shown.
Binary file modified clown3d-DS.nds
Binary file not shown.
13 changes: 4 additions & 9 deletions collisions.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
#include <stdlib.h>
#include "headers.h"

float avoidZero(float f)
{
return f;
}

/* Compares using absolute values, equivalent
to measuring the magnitude of a 1-dimensional
vector. Ignores zero-length values as
Expand Down Expand Up @@ -99,9 +94,9 @@ float smallestOfThree(float a, float b, float c)
*/ \
\
ratio = smallestOfThree \
(x_offs /avoidZero(node->box.move.x), \
y_offs / avoidZero(node->box.move.y), \
z_offs / avoidZero(node->box.move.z)); \
(x_offs / node->box.move.x, \
y_offs / node->box.move.y, \
z_offs / node->box.move.z); \
\
/* Cheap way to avoid glitches. Normally, \
ratio should be between 0 and 1. */ \
Expand Down Expand Up @@ -150,7 +145,7 @@ void resolveCollisions(game_obj* objs, void (*handler)(void*, void*))
game_obj *node, *node2;

for(node = objs; node != NULL; node = node->next) {
if(node->type == SOLID) continue; /* SOLIDs don't move ! */
if(node->type == SOLID) continue; /* heuristic: SOLIDs don't move ! */
for(node2 = objs; node2 != NULL; node2 = node2->next) {
if(node != node2 && node->type != NONE && node2->type != NONE) {
/* Check if any of the current boxe's
Expand Down
Loading

0 comments on commit fd22b65

Please sign in to comment.