Here’s the full main.cpp
#include "Core.hpp"
#include "Load.hpp"
#include "Create.hpp"
#include <vector>
int main(int argc, char *argv[]){
Core core;
Load load;
Create* player;
Create *enemy[10];
core.init("window", 0, 0, 1080, 720, false);
float p_x = 1080/2, p_y = 720 - 64 * 2;
int p_acc = 2;
player = new Create("../assets/player.png");
int i = 1;
for (i = 1; i<=10; i++) {
enemy[i] = new Create("../assets/enemy.png");
}
int j = 1;
while (core.is_running) {
player -> update(p_x, p_y);
core.start_render();
player -> render();
while(j <= 10){
enemy[j] -> update(rand()% 100, rand() % 100);
enemy[j] -> render();
std::cout << "loop exits" << i << std::endl;
j++;
}
core.clear_render();
core.handle_events();
if (core.key[4] == true){
p_x += 0.5 * p_acc;
//std::cout << "x pos" << p_x << std::endl;
}
if (core.key[3] == true)
p_x -= 0.5 * p_acc;
}
core.update();
return 0;
}
I tried storing 10 enemy objects in the array.
It all looks ok to me but i can’t see any enemy on the screen (i checked the path to the image)