I am making a game on a PIC18F2550 and I need to create a random number between 1 and 4. I've found out already that the rand() function sucks for truly random numbers. I've tried the srand(time(NULL)), this is the main file
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
void main(void) {
srand(time(NULL));
init();
while(timed_to_1ms()) {
fsm_game();
}
}
this is the fsm_game.c file
void randomSpawn(int time2) {
if(counter%time2==0) {
int x = rand()%4 +1; // Makes number between 1 and 4
}
}
When I try to build this I get an error saying:
":0: error: (499) undefined symbol: _time(dist/default/production\Dontcrash.production.obj) "
I think the problem may be in the fact that a microProcessor doesn't 'know the time', so if that's the case, what can I do to solve this problem?
Aucun commentaire:
Enregistrer un commentaire