|
|
|
@ -1,28 +1,83 @@
|
|
|
|
#include "raylib.h"
|
|
|
|
#include "raylib.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct Sprite{
|
|
|
|
|
|
|
|
Texture2D *texture;
|
|
|
|
|
|
|
|
float x;
|
|
|
|
|
|
|
|
float y;
|
|
|
|
|
|
|
|
} Sprite;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void addSprite(struct Sprite *cursors, int *j, Texture2D *texture, int x, int y){
|
|
|
|
|
|
|
|
if(*j < 100){
|
|
|
|
|
|
|
|
(cursors + *j) -> texture = texture;
|
|
|
|
|
|
|
|
(cursors + *j) -> x = x;
|
|
|
|
|
|
|
|
(cursors + *j) -> y = y;
|
|
|
|
|
|
|
|
(*j)++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
printf("Voll\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main(){
|
|
|
|
int main(){
|
|
|
|
|
|
|
|
|
|
|
|
Texture2D sprite;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float posX = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InitWindow(800, 450, "basic window");
|
|
|
|
InitWindow(800, 450, "basic window");
|
|
|
|
|
|
|
|
|
|
|
|
sprite = LoadTexture("amulet.png");
|
|
|
|
Texture2D texture;
|
|
|
|
|
|
|
|
struct Sprite sprites[100];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
texture = LoadTexture("amulet.png");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int j = 0;
|
|
|
|
|
|
|
|
struct Sprite cursor = {&texture, 450, 225};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Camera2D camera = { 0 };
|
|
|
|
|
|
|
|
camera.target = (Vector2){400, 225};
|
|
|
|
|
|
|
|
camera.rotation = 0.0f;
|
|
|
|
|
|
|
|
camera.zoom = 1.0f;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SetTargetFPS(60);
|
|
|
|
SetTargetFPS(60);
|
|
|
|
while(!WindowShouldClose()){
|
|
|
|
while(!WindowShouldClose()){
|
|
|
|
|
|
|
|
|
|
|
|
posX += GetFrameTime() * 100;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BeginDrawing();
|
|
|
|
BeginDrawing();
|
|
|
|
|
|
|
|
|
|
|
|
ClearBackground(RAYWHITE);
|
|
|
|
ClearBackground(RAYWHITE);
|
|
|
|
|
|
|
|
|
|
|
|
DrawTexture(sprite, 10, 10, WHITE);
|
|
|
|
BeginMode2D(camera);
|
|
|
|
|
|
|
|
int i;
|
|
|
|
DrawRectangle(posX,100,100,100, BLUE);
|
|
|
|
int length = sizeof(sprites)/sizeof(sprites[0]);
|
|
|
|
|
|
|
|
for(i=0; i < j; i++){
|
|
|
|
|
|
|
|
DrawTexture(*sprites[i].texture, sprites[i].x, sprites[i].y, WHITE);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
EndMode2D();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DrawTexture(*cursor.texture, cursor.x, cursor.y, WHITE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cursor.x = GetMousePosition().x - texture.width / 2;
|
|
|
|
|
|
|
|
cursor.y = GetMousePosition().y - texture.height / 2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)){
|
|
|
|
|
|
|
|
printf("Klick\n");
|
|
|
|
|
|
|
|
addSprite(sprites, &j, &texture, cursor.x + camera.target.x, cursor.y + camera.target.y);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(IsKeyDown(KEY_W)){
|
|
|
|
|
|
|
|
camera.target.y -= 100.0f * GetFrameTime();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(IsKeyDown(KEY_S)){
|
|
|
|
|
|
|
|
camera.target.y += 100.0f * GetFrameTime();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(IsKeyDown(KEY_D)){
|
|
|
|
|
|
|
|
camera.target.x += 100.0f * GetFrameTime();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(IsKeyDown(KEY_A)){
|
|
|
|
|
|
|
|
camera.target.x -= 100.0f * GetFrameTime();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EndDrawing();
|
|
|
|
EndDrawing();
|
|
|
|
@ -33,4 +88,4 @@ int main(){
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|