4
0

Compare commits

...

2 Commits

Author SHA1 Message Date
6cba6edb2e add GEMINI.md
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2025-12-09 08:14:35 +01:00
438a334f95 newlines 2025-12-09 08:14:22 +01:00
2 changed files with 156 additions and 17 deletions

48
GEMINI.md Normal file
View File

@@ -0,0 +1,48 @@
# TIC-80 Lua Code Regularities
Based on the analysis of `mranderson.lua`, the following regularities and conventions should be followed for future modifications and development within this project:
## General Structure & Lifecycle
1. **TIC-80 Game Loop:** All primary game logic, updates, and rendering should be encapsulated within the `TIC()` function, which serves as the main entry point for each frame of the TIC-80 game cycle.
2. **Initialization:** Game state variables and one-time setup should occur at the global scope or within a dedicated initialization function called once.
## Naming Conventions
3. **Functions:** Custom function names should use `PascalCase` (e.g., `UpdatePlayer`, `DrawHUD`). Existing mathematical helper functions like `SQR()` are an exception.
4. **Variables:** Variables should use `snake_case` (e.g., `player_x`, `game_state`), aligning with the existing `flip_x` variable.
5. **Constants:** Constants should be named using `SCREAMING_SNAKE_CASE` (e.g., `MAX_SPEED`, `GRAVITY_STRENGTH`).
## Variable Handling & Grouping
6. **Global Variables:** Major game state variables (e.g., position, velocity, animation frames) are typically defined at the global scope for easy access throughout the game loop.
7. **Lua Tables for Grouping:** Collections of related data should be grouped into Lua tables for better organization and readability (e.g., `player = {x = 0, y = 0, speed = 1}`).
8. **Table Formatting:** Tables with multiple elements or complex structures should always be defined with line breaks for each key-value pair, rather than inline, to improve readability.
Example:
```lua
my_table = {
key1 = value1,
key2 = value2,
}
```
instead of `my_table = {key1 = value1, key2 = value2}`.
## Functions
9. **Helper Functions:** Reusable logic or common calculations should be extracted into separate, clearly named helper functions.
## Input Handling
10. **`btn()` for Input:** User input should be handled primarily through the TIC-80 `btn()` function, checking for specific button presses or states.
## Graphics & Rendering
11. **`spr()` for Sprites:** Individual sprites should be rendered using the `spr()` function.
12. **`map()` for Maps:** Tilemaps should be drawn using the `map()` function.
13. **`print()` for Text:** Text display should utilize the `print()` function.
## Code Style
14. **Indentation:** Use consistent indentation, likely 2 spaces, for code blocks to enhance readability.
15. **Comments:** Employ comments to explain complex logic, delineate code sections, or clarify non-obvious design choices.
16. **Code Sections:** Use comments (e.g., `--- INIT ---`, `--- UPDATE ---`, `--- DRAW ---`, `--- HELPERS ---`) to clearly delineate logical sections of the codebase.

View File

@@ -113,43 +113,134 @@ local State = {
{ -- Screen 1
name = "Screen 1",
platforms = {
{x = 80, y = 110, w = 40, h = 8},
{x = 160, y = 90, w = 40, h = 8}
{
x = 80,
y = 110,
w = 40,
h = 8
},
{
x = 160,
y = 90,
w = 40,
h = 8
}
},
npcs = {
{x = 180, y = 82, name = "Trinity", sprite_id = 2},
{x = 90, y = 102, name = "Oracle", sprite_id = 3}
{
x = 180,
y = 82,
name = "Trinity",
sprite_id = 2
},
{
x = 90,
y = 102,
name = "Oracle",
sprite_id = 3
}
},
items = {
{x = 100, y = 128, w=8, h=8, name = "Key", sprite_id = 4, desc = "A rusty old key. It might open something."}
{
x = 100,
y = 128,
w = 8,
h = 8,
name = "Key",
sprite_id = 4,
desc = "A rusty old key. It might open something."
}
}
},
{ -- Screen 2
name = "Screen 2",
platforms = {
{x = 30, y = 100, w = 50, h = 8},
{x = 100, y = 80, w = 50, h = 8},
{x = 170, y = 60, w = 50, h = 8}
{
x = 30,
y = 100,
w = 50,
h = 8
},
{
x = 100,
y = 80,
w = 50,
h = 8
},
{
x = 170,
y = 60,
w = 50,
h = 8
}
},
npcs = {
{x = 120, y = 72, name = "Morpheus", sprite_id = 5},
{x = 40, y = 92, name = "Tank", sprite_id = 6}
{
x = 120,
y = 72,
name = "Morpheus",
sprite_id = 5
},
{
x = 40,
y = 92,
name = "Tank",
sprite_id = 6
}
},
items = {
{x = 180, y = 52, w=8, h=8, name = "Potion", sprite_id = 7, desc = "A glowing red potion. It looks potent."}
{
x = 180,
y = 52,
w = 8,
h = 8,
name = "Potion",
sprite_id = 7,
desc = "A glowing red potion. It looks potent."
}
}
},
{ -- Screen 3
name = "Screen 3",
platforms = {
{x = 50, y = 110, w = 30, h = 8},
{x = 100, y = 90, w = 30, h = 8},
{x = 150, y = 70, w = 30, h = 8},
{x = 200, y = 50, w = 30, h = 8}
{
x = 50,
y = 110,
w = 30,
h = 8
},
{
x = 100,
y = 90,
w = 30,
h = 8
},
{
x = 150,
y = 70,
w = 30,
h = 8
},
{
x = 200,
y = 50,
w = 30,
h = 8
}
},
npcs = {
{x = 210, y = 42, name = "Agent Smith", sprite_id = 8},
{x = 160, y = 62, name = "Cypher", sprite_id = 9}
{
x = 210,
y = 42,
name = "Agent Smith",
sprite_id = 8
},
{
x = 160,
y = 62,
name = "Cypher",
sprite_id = 9
}
},
items = {}
}