mouse support, solved some funcs clash on linux, started sprite editor
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
mini.exe
|
||||
mini
|
||||
|
||||
29
.vscode/launch.json
vendored
29
.vscode/launch.json
vendored
@@ -1,29 +0,0 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "g++.exe - Compilar y depurar el archivo activo",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${fileDirname}\\mini.exe",
|
||||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${fileDirname}",
|
||||
"environment": [],
|
||||
"externalConsole": false,
|
||||
"MIMode": "gdb",
|
||||
"miDebuggerPath": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\gdb.exe",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Habilitar la impresión con sangría para gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
],
|
||||
"preLaunchTask": "C/C++: g++.exe compilar archivo activo"
|
||||
}
|
||||
]
|
||||
}
|
||||
8
.vscode/settings.json
vendored
8
.vscode/settings.json
vendored
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"cmath": "cpp",
|
||||
"*.tcc": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"cstdlib": "cpp"
|
||||
}
|
||||
}
|
||||
32
.vscode/tasks.json
vendored
32
.vscode/tasks.json
vendored
@@ -1,32 +0,0 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"type": "cppbuild",
|
||||
"label": "C/C++: g++.exe compilar archivo activo",
|
||||
"command": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe",
|
||||
"args": [
|
||||
"-g",
|
||||
"*.cpp",
|
||||
"./lua/*.c",
|
||||
"-lmingw32",
|
||||
"-lSDL2main",
|
||||
"-lSDL2",
|
||||
//"-mwindows",
|
||||
"-o",
|
||||
"${fileDirname}\\mini.exe"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${fileDirname}"
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$gcc"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"detail": "compilador: \"C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe\""
|
||||
}
|
||||
]
|
||||
}
|
||||
13
main.cpp
13
main.cpp
@@ -8,8 +8,17 @@ void do_terminal() {
|
||||
}
|
||||
|
||||
void do_sprite_editor() {
|
||||
cls();
|
||||
sspr(0, 0, 8, 8, 8, 8, 64, 64);
|
||||
cls(14);
|
||||
palt(0, false);
|
||||
rectfill(0, 0, 160, 7, 2);
|
||||
rectfill(0, 115, 160, 119, 2);
|
||||
sspr(0, 0, 128, 32, 0, 83);
|
||||
sspr(0, 0, 8, 8, 8, 16, 64, 64);
|
||||
rect(8, 16, 72, 80, 0);
|
||||
spr(17, mouseX(), mouseY());
|
||||
if (mouseButton(1) && mouseX()>=8 && mouseY()>=8 && mouseX()<72 && mouseY()<72) {
|
||||
sset((mouseX()-8)/8, (mouseY()-16)/8);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
31
mini.cpp
31
mini.cpp
@@ -58,6 +58,9 @@ int debug_cursor = 0;
|
||||
const Uint8 *keys;
|
||||
Uint8 key_just_pressed = 0;
|
||||
|
||||
int mouse_x, mouse_y;
|
||||
Uint32 mouse_buttons;
|
||||
|
||||
void reinit() {
|
||||
ds::pen_color = 6;
|
||||
ds::cam[0] = ds::cam[1] = 0;
|
||||
@@ -130,7 +133,9 @@ int main(int argc,char*argv[]){
|
||||
}
|
||||
}
|
||||
keys = SDL_GetKeyboardState(NULL);
|
||||
|
||||
mouse_buttons = SDL_GetMouseState(&mouse_x, &mouse_y);
|
||||
mouse_x /= 4; mouse_y /= 4;
|
||||
|
||||
if (lua_is_playing()) {
|
||||
lua_call_update();
|
||||
} else {
|
||||
@@ -595,6 +600,18 @@ bool btnp(uint8_t i) {
|
||||
return key_just_pressed == i;
|
||||
}
|
||||
|
||||
int mouseX() {
|
||||
return mouse_x;
|
||||
}
|
||||
|
||||
int mouseY() {
|
||||
return mouse_y;
|
||||
}
|
||||
|
||||
bool mouseButton(uint8_t i) {
|
||||
return mouse_buttons & SDL_BUTTON(i);
|
||||
}
|
||||
|
||||
float time() {
|
||||
return float(SDL_GetTicks())/1000.0f;
|
||||
}
|
||||
@@ -603,10 +620,6 @@ float time() {
|
||||
return SDL_fabsf(x);
|
||||
}*/
|
||||
|
||||
float ceil(float x) {
|
||||
return SDL_ceilf(x);
|
||||
}
|
||||
|
||||
float flr(float x) {
|
||||
return SDL_floorf(x);
|
||||
}
|
||||
@@ -615,6 +628,12 @@ float sgn(float x) {
|
||||
return x >= 0 ? 1 : -1;
|
||||
}
|
||||
|
||||
#ifndef __LINUX__
|
||||
|
||||
float ceil(float x) {
|
||||
return SDL_ceilf(x);
|
||||
}
|
||||
|
||||
float sin(float x) {
|
||||
return SDL_sinf(x);
|
||||
}
|
||||
@@ -631,6 +650,8 @@ float sqrt(float x) {
|
||||
return SDL_sqrtf(x);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
float max(float x, float y) {
|
||||
return SDL_max(x, y);
|
||||
}
|
||||
|
||||
9
mini.h
9
mini.h
@@ -181,17 +181,24 @@ void map(uint8_t celx, uint8_t cely, int sx, int sy, uint8_t celw, uint8_t celh,
|
||||
bool btn(uint8_t i);
|
||||
bool btnp(uint8_t i);
|
||||
|
||||
int mouseX();
|
||||
int mouseY();
|
||||
bool mouseButton(uint8_t i);
|
||||
|
||||
float time();
|
||||
|
||||
//float abs(float x);
|
||||
float ceil(float x);
|
||||
|
||||
float flr(float x);
|
||||
float sgn(float x);
|
||||
|
||||
#ifndef __LINUX__
|
||||
float ceil(float x);
|
||||
float sin(float x);
|
||||
float cos(float x);
|
||||
float atan2(float dx, float dy);
|
||||
float sqrt(float x);
|
||||
#endif
|
||||
|
||||
float max(float x, float y);
|
||||
float mid(float x, float y, float z);
|
||||
|
||||
Reference in New Issue
Block a user