I figured it out! It feels good to actually get something working. I had forgotten to add the storyboard module in the makefile. After getting continual errors and warnings, I realized I didn't even need the extra C file. The communication between the three files was just a nightmare. I just dumped the code into the header file and made some alterations. Below is what I did, so others can execute the same thing for their projects:
MAKEFILE LINE:
JO_COMPILE_WITH_STORYBOARD_MODULE = 1
HEADER:
#ifndef __STORYBOARD_H__
# define __STORYBOARD_H__
#include <jo/jo.h>
// A custom structure to show that you can use customs as well as jo_2d_object_attributes, jo_pos2D, etc.
typedef struct
{
/* Must be the first field in our custom structure in order to let the storyboard retrieve where the location of our object is */
jo_2d_object_attributes attributes;
int sprite_id;
// Add other attributes here or not ;)
} circular_saw_t;
static circular_saw_t saws[2];
static jo_pos2D drone;
static jo_pos2D sentry;
static int sentry_sprite_id;
static int drone_sprite_id;
static jo_storyboard *drone_storyboard;
void animate_circular_saws(void)
{
jo_storyboard *storyboard;
jo_animation *animation;
// We create a new storyboard for all saw (that means that you can use the same storyboard with multiple object)
storyboard = jo_storyboard_create(true, false);
// Now we add a new custom animation (smooth translation + rotation) (that means that you can add multiple animation)
animation = jo_storyboard_create_animation(storyboard, 0, 0);
animation->sin_radius = 80;
animation->translation_speed_y = 2;
animation->rotation_speed = 10;
// Now we can animate any object
jo_storyboard_add_object(storyboard, &saws[0]);
jo_storyboard_add_object(storyboard, &saws[1]);
// Next step in my_draw()
}
void animate_drone(void)
{
//jo_storyboard_create_for_object() = jo_storyboard_create() + jo_storyboard_add_object()
drone_storyboard = jo_storyboard_create_for_object(true, true, &drone);
jo_storyboard_create_translation_animation_using_direction(drone_storyboard, RIGHT, 1, 160);
jo_storyboard_create_translation_animation_using_direction(drone_storyboard, DOWN, 1, 160);
jo_storyboard_create_translation_animation_using_direction(drone_storyboard, LEFT, 1, 160);
// You can also translate in any direction (angle)
jo_storyboard_create_translation_animation(drone_storyboard, 270, 1, 160);
// You can create complex animation :)
}
void animate_sentry(void)
{
// There is many powerful helpers in jo/storyboard.h
// jo_storyboard_move_object_in_circle() = jo_storyboard_create() + jo_storyboard_add_object() + jo_storyboard_create_circle_animation()
jo_storyboard_move_object_in_circle(&sentry, 90, 1, JO_STORYBOARD_INFINITE_DURATION);
}
void init_circular_saw_sprite_and_position(void)
{
// First saw
saws[0].attributes.z = 500;
saws[0].attributes.x = -50;
saws[0].sprite_id = jo_sprite_add_tga(JO_ROOT_DIR, "SAW.TGA", JO_COLOR_Green);
// Second saw
saws[1].attributes.x = 50;
saws[1].attributes.z = saws[0].attributes.z; // Same z position
saws[1].sprite_id = saws[0].sprite_id; // Same sprite
}
void init_drone_sprite_and_position(void)
{
drone_sprite_id = jo_sprite_add_tga(JO_ROOT_DIR, "EMY.TGA", JO_COLOR_Green);
drone.x = -80;
drone.y = -80;
}
void init_sentry_sprite_and_position(void)
{
sentry_sprite_id = jo_sprite_add_tga(JO_ROOT_DIR, "CAM.TGA", JO_COLOR_Green);
sentry.x = 0;
sentry.y = 0;
}
#endif /* !__STORYBOARD_H__ */
/*
** END OF FILE
*/
So I took out the gamepad part, because I didn't need it. I moved the important info in my_draw and jo_main to my main file, and deleted those sections in the header file. Here is the needed code in the main C file:
#include "storyboard.h"
void my_draw(void)
{
jo_sprite_draw3D_and_rotate(saws[0].sprite_id, saws[0].attributes.x, saws[0].attributes.y, saws[0].attributes.z, saws[0].attributes.rz);
jo_sprite_draw3D_and_rotate(saws[1].sprite_id, saws[1].attributes.x, saws[1].attributes.y, saws[1].attributes.z, saws[1].attributes.rz);
jo_sprite_draw3D(drone_sprite_id, drone.x, drone.y, 550);
jo_sprite_draw3D(sentry_sprite_id, sentry.x, sentry.y, 400);
}
void jo_main(void)
{
init_circular_saw_sprite_and_position();
init_drone_sprite_and_position();
init_sentry_sprite_and_position();
animate_circular_saws();
animate_drone();
animate_sentry();
}
There you have it! Thanks, ponut64!