Sign in to follow this  

pre compiling various stuff

This topic is 3595 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How can I "precompile" everything except one cpp file so that people can put their own code in that file but can't edit the other source files at all (includeing not being able to see the code in them)? I don't mind to much if the headers can't be precompiled as there just declarations but I really want the cpp files compiled to a stage that it's not practicle for people to get at the code. Example of file for the user to edit: -creating a very basic particle system
#include "base.h"//includes headers for all the other source files and sets up globals.

int mysys, mypart;

//this is at the very start of the game before even the window is created
void pre_game()
{
	//width of our window
	window_width = 800;
	//height of our window
	window_height = 600;
	//should the window be fullscreen?
	fullscreen = false;
	//caption given to our game window
	caption = "Particel system example";
	//number of steps per second -NOTE: this can be changed mid game.
	game_speed = 30;
	//ARGB hex value -NOTE: this can be changed mid game
	background_colour = 0xFF000000;
	//write minor errors/warnings to error_log.txt
	error_log = true;


	//create a new particle system
	mysys = part_system_create();

	//give the system a new particle type
	mypart = part_type_create(mysys, pt_type_pixel);
	//particles have a random speed between 8 and 10
	part_type_speed    (mysys, mypart, 8, 10);
	//particles always move towards the right
	part_type_direction(mysys, mypart, 0, 0);
	//particles live for 90 steps (or 3 seconds)
	part_type_life     (mysys, mypart, 90, 90;

	//particle colour is solid white with no varience
	pt_colour colour;
	colour.c1_a = 0xFF; colour.c2_a = 0xFF;
	colour.c1_r = 0xFF; colour.c2_r = 0xFF;
	colour.c1_g = 0xFF; colour.c2_g = 0xFF;
	colour.c1_b = 0xFF; colour.c2_b = 0xFF;
	part_type_colour(mysys, mypart, &colour);

	//create a new emitter for our system
	int myem = part_emitter_create(mysys);
	part_emitter_area(mysys, myem, 0, 0, 0, 600);
	part_emitter_rate(mysys, myem, 5);
	part_emitter_type(mysys, myem, mypart);

}

//just before the main loop. Now that everything has been created it's safe to load sprites etc which need d3d to be started
void pre_loop()
{

}
//at the start of each loop
void step_start()
{
	//update the particle system
	part_system_update(mysys);
}
//before objects are drawn
void draw_start()
{
	//draw all particles of this type in the system
	part_system_draw_type(mysys, mypart, 0);
}
//after the objects have been drawn
void draw_end()
{

}
//run right at the end of the loop after the draw events
void step_end()
{

}

void game_end()
{

}


Share this post


Link to post
Share on other sites
How do I have the libary contain the entry point and have it call the functions in the users code at the correct times?

Right now vs compiles everything fine except main.cpp which is what calls the functions in the user file because it can't find the functions that I want in that file... Do I need to create a header declaring but not defining the functions or somthing?

Share this post


Link to post
Share on other sites
test.lib(main.obj) : error LNK2019: unresolved external symbol "void __cdecl pre_game(void)" (?pre_game@@YAXXZ) referenced in function _WinMain@16

test.h

#include <string>

#pragma comment (lib, "lib/test.lib")
#include "lib/draw_base.h"
#include "lib/draw_sprite.h"
#include "lib/maths.h"
#include "lib/particle.h"
#include "lib/object.h"
#include "lib/collision.h"
#include "lib/input.h"

extern bool error_log, game_run, fullscreen;
extern int mouse_x, mouse_y;
extern unsigned short game_speed, window_width, window_height;
extern unsigned long background_colour;
extern std::string caption;

void pre_gmae();
void pre_loop();
void step_start();
void draw_start();
void draw_end();
void step_end();
void game_end();



game.cpp

#include "test.h"
void pre_gmae()
{

}
void pre_loop()
{

}
void step_start()
{

}
void draw_start()
{

}
void draw_end()
{

}
void step_end()
{

}
void game_end()
{

}


Share this post


Link to post
Share on other sites

This topic is 3595 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this