|
|
|
@ -1,6 +1,7 @@
|
|
|
|
#include "raylib.h"
|
|
|
|
#include "raylib.h"
|
|
|
|
#include "stdio.h"
|
|
|
|
#include "stdio.h"
|
|
|
|
#include "sprite.h"
|
|
|
|
#include "sprite.h"
|
|
|
|
|
|
|
|
#include "raymath.h"
|
|
|
|
|
|
|
|
|
|
|
|
int main(){
|
|
|
|
int main(){
|
|
|
|
|
|
|
|
|
|
|
|
@ -11,6 +12,13 @@ int main(){
|
|
|
|
Texture2D texture;
|
|
|
|
Texture2D texture;
|
|
|
|
struct Sprite sprites[100];
|
|
|
|
struct Sprite sprites[100];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int destX = 0;
|
|
|
|
|
|
|
|
int destY = 0;
|
|
|
|
|
|
|
|
int clicked = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int pressed = 0;
|
|
|
|
|
|
|
|
Vector2 rectStart = {0,0};
|
|
|
|
|
|
|
|
|
|
|
|
texture = LoadTexture("amulet.png");
|
|
|
|
texture = LoadTexture("amulet.png");
|
|
|
|
|
|
|
|
|
|
|
|
int j = 0;
|
|
|
|
int j = 0;
|
|
|
|
@ -21,6 +29,8 @@ int main(){
|
|
|
|
camera.rotation = 0.0f;
|
|
|
|
camera.rotation = 0.0f;
|
|
|
|
camera.zoom = 1.0f;
|
|
|
|
camera.zoom = 1.0f;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addSprite(sprites, &j, &texture, cursor.x + camera.target.x, cursor.y + camera.target.y);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SetTargetFPS(60);
|
|
|
|
SetTargetFPS(60);
|
|
|
|
@ -44,10 +54,39 @@ int main(){
|
|
|
|
cursor.x = GetMousePosition().x - texture.width / 2;
|
|
|
|
cursor.x = GetMousePosition().x - texture.width / 2;
|
|
|
|
cursor.y = GetMousePosition().y - texture.height / 2;
|
|
|
|
cursor.y = GetMousePosition().y - texture.height / 2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)){
|
|
|
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)){
|
|
|
|
printf("Klick\n");
|
|
|
|
printf("Klick\n");
|
|
|
|
addSprite(sprites, &j, &texture, cursor.x + camera.target.x, cursor.y + camera.target.y);
|
|
|
|
addSprite(sprites, &j, &texture, cursor.x + camera.target.x, cursor.y + camera.target.y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(IsMouseButtonPressed(MOUSE_BUTTON_LEFT)){
|
|
|
|
|
|
|
|
if(pressed == 0){
|
|
|
|
|
|
|
|
rectStart.x = cursor.x;
|
|
|
|
|
|
|
|
rectStart.y = cursor.y;
|
|
|
|
|
|
|
|
pressed = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(pressed){
|
|
|
|
|
|
|
|
float width = GetMousePosition().x - rectStart.x;
|
|
|
|
|
|
|
|
float height = GetMousePosition().y - rectStart.y;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DrawRectangleLines(rectStart.x, rectStart.y, width, height, GREEN);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT)){
|
|
|
|
|
|
|
|
pressed = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)){
|
|
|
|
|
|
|
|
clicked = 1;
|
|
|
|
|
|
|
|
destX = cursor.x + camera.target.x;
|
|
|
|
|
|
|
|
destY = cursor.y + camera.target.y;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(IsKeyDown(KEY_W)){
|
|
|
|
if(IsKeyDown(KEY_W)){
|
|
|
|
camera.target.y -= 100.0f * GetFrameTime();
|
|
|
|
camera.target.y -= 100.0f * GetFrameTime();
|
|
|
|
@ -62,6 +101,19 @@ int main(){
|
|
|
|
camera.target.x -= 100.0f * GetFrameTime();
|
|
|
|
camera.target.x -= 100.0f * GetFrameTime();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(clicked){
|
|
|
|
|
|
|
|
Vector2 movement = {destX - sprites->x, destY - sprites->y};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(Vector2Length(movement) < 10.0f){
|
|
|
|
|
|
|
|
clicked = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
movement = Vector2Normalize(movement);
|
|
|
|
|
|
|
|
movement = Vector2Scale(movement, 10);
|
|
|
|
|
|
|
|
sprites->x += movement.x;
|
|
|
|
|
|
|
|
sprites->y += movement.y;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EndDrawing();
|
|
|
|
EndDrawing();
|
|
|
|
|
|
|
|
|
|
|
|
|