refactor: Remove ES6 module syntax and reorder script loading

This commit is contained in:
Kacper Kostka (aider) 2025-04-02 11:52:06 +02:00
parent 8057ba881b
commit a002d4b017
3 changed files with 4 additions and 6 deletions

5
ai.js
View File

@ -6,8 +6,7 @@ const ANIMAL_HUNGER_MAX = 100;
/********************************************************************** /**********************************************************************
* CITIZEN AI * CITIZEN AI
**********************************************************************/ **********************************************************************/
// Export functions function updateCitizen(cit) {
export function updateCitizen(cit) {
cit.hunger += HUNGER_INCREMENT; cit.hunger += HUNGER_INCREMENT;
if(cit.hunger > HUNGER_MAX) cit.hunger = HUNGER_MAX; if(cit.hunger > HUNGER_MAX) cit.hunger = HUNGER_MAX;
@ -54,7 +53,7 @@ export function updateCitizen(cit) {
/********************************************************************** /**********************************************************************
* ANIMAL AI * ANIMAL AI
**********************************************************************/ **********************************************************************/
export function updateAnimal(ani) { function updateAnimal(ani) {
if(ani.type === "Rabbit") { if(ani.type === "Rabbit") {
updateRabbit(ani); updateRabbit(ani);
} }

View File

@ -1,8 +1,7 @@
/********************************************************************** /**********************************************************************
* GAME CORE * GAME CORE
**********************************************************************/ **********************************************************************/
// Import AI functions // AI functions are defined in ai.js and loaded via script tag
import { updateCitizen, updateAnimal } from './ai.js';
let frameCount = 0; let frameCount = 0;
let money = 5000; // Start with 5000 let money = 5000; // Start with 5000
let purchaseMode = null; let purchaseMode = null;

View File

@ -207,12 +207,12 @@
<div id="log"></div> <div id="log"></div>
</div> </div>
<script src="game.js"></script>
<script src="entities.js"></script> <script src="entities.js"></script>
<script src="utils.js"></script> <script src="utils.js"></script>
<script src="ai.js"></script> <script src="ai.js"></script>
<script src="render.js"></script> <script src="render.js"></script>
<script src="events.js"></script> <script src="events.js"></script>
<script src="game.js"></script>
<script> <script>
/********************************************************************** /**********************************************************************