diff --git a/app/games/Game.tsx b/app/games/Game.tsx deleted file mode 100644 index eb5e10c..0000000 --- a/app/games/Game.tsx +++ /dev/null @@ -1,113 +0,0 @@ -"use client"; -import { useEffect, useRef } from "react"; -import * as PIXI from "pixi.js"; -import Matter from "matter-js"; - -export default function Game() { - const containerRef = useRef(null); - - useEffect(() => { - const app = new PIXI.Application(); - - app.init({ - width: 800, - height: 600, - backgroundColor: 0x1099bb, - }).then(() => { - containerRef.current?.appendChild(app.view as unknown as Node); - - // --- Matter setup --- - const engine = Matter.Engine.create(); - engine.gravity.y = 0; // top-down style (no falling) - - const balls: { body: Matter.Body; gfx: PIXI.Graphics }[] = []; - - // Function to create a ball - function createBall( - x: number, - y: number, - radius = 30, - color = 0xff0000 - ) { - const body = Matter.Bodies.circle(x, y, radius, { - restitution: 0.8, // bounciness - friction: 0.1, - }); - Matter.World.add(engine.world, body); - - const gfx = new PIXI.Graphics(); - gfx.beginFill(color).drawCircle(0, 0, radius).endFill(); - app.stage.addChild(gfx); - - balls.push({ body, gfx }); - } - - // Create draggable ball (special one) - createBall(200, 300, 40, 0x00ff00); - - // Create some other balls - for (let i = 0; i < 5; i++) { - createBall(400 + i * 70, 300, 30, 0xffaa00); - } - - // Track dragging - let dragConstraint: Matter.Constraint | null = null; - - app.stage.eventMode = "static"; // enable pointer events - app.stage.hitArea = app.screen; - - app.stage.on("pointerdown", (e: PIXI.FederatedPointerEvent) => { - const pos = e.global; - - // Find ball under pointer - const picked = balls.find((b) => - Matter.Bounds.contains(b.body.bounds, { - x: pos.x, - y: pos.y, - }) - ); - - if (picked) { - dragConstraint = Matter.Constraint.create({ - pointA: { x: pos.x, y: pos.y }, - bodyB: picked.body, - stiffness: 0.1, - damping: 0.1, - }); - Matter.World.add(engine.world, dragConstraint); - } - }); - - app.stage.on("pointermove", (e: PIXI.FederatedPointerEvent) => { - if (dragConstraint) { - dragConstraint.pointA = { x: e.global.x, y: e.global.y }; - } - }); - - app.stage.on("pointerup", () => { - if (dragConstraint) { - Matter.World.remove(engine.world, dragConstraint); - dragConstraint = null; - } - }); - - // Game Loop - app.ticker.add((ticker) => { - Matter.Engine.update(engine, 1000 / 60); - - // Sync Matter bodies to Pixi graphics - for (const { body, gfx } of balls) { - gfx.x = body.position.x; - gfx.y = body.position.y; - gfx.rotation = body.angle; - } - }); - }); - - return () => { - app.destroy(true, true); - }; - }, []); - - return
; -} diff --git a/app/games/PythonFlappyBird.css b/app/games/flappy-bird-py/PythonFlappyBird.css similarity index 100% rename from app/games/PythonFlappyBird.css rename to app/games/flappy-bird-py/PythonFlappyBird.css diff --git a/app/games/PythonFlappyBird.tsx b/app/games/flappy-bird-py/PythonFlappyBird.tsx similarity index 100% rename from app/games/PythonFlappyBird.tsx rename to app/games/flappy-bird-py/PythonFlappyBird.tsx diff --git a/app/routes.ts b/app/routes.ts index b3940e4..d5dba77 100644 --- a/app/routes.ts +++ b/app/routes.ts @@ -2,9 +2,8 @@ import { type RouteConfig, index, route } from "@react-router/dev/routes"; export default [ index("routes/Home.tsx"), - route("pythonFlappyBird", "games/PythonFlappyBird.tsx"), + route("/games/pythonFlappyBird", "games/flappy-bird-py/PythonFlappyBird.tsx"), route("/games/pokemon", "games/pokemon/PokemonBattleAI.tsx"), - route("/games/physics", "games/Game.tsx"), route("/games/pong-game-js", "games/pong-game-js/page.tsx"), route("/games/flappy-bird-js", "games/flappy-bird-js/componentes/Page.tsx") ] satisfies RouteConfig; diff --git a/app/routes/Home.tsx b/app/routes/Home.tsx index 8df44ed..ccc1611 100644 --- a/app/routes/Home.tsx +++ b/app/routes/Home.tsx @@ -25,7 +25,7 @@ const games: GameLink[] = [ name: "Flappy Bird AI", description: "Uma IA em Python que aprende a jogar Flappy Bird sozinha!", image: "/PythonFlappyBird/FlappyBirdIcon.png", - url: "/pythonFlappyBird", + url: "/games/pythonFlappyBird", }, { name: "Pokemon Battle AI", @@ -33,13 +33,6 @@ const games: GameLink[] = [ image: "/Pokemon/PokemonIcon.svg", url: "/games/pokemon", }, - { - name: "Physics Sandbox", - description: "Experimente a física com bolas e colisões!", - image: "", - icon: "🌟", - url: "/games/physics", - }, { name: "Pong AI", description: "Jogue Pong contra uma IA desafiadora!", diff --git a/package-lock.json b/package-lock.json index 14dbc7d..64297fd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,8 @@ "react": "^19.1.0", "react-dom": "^19.1.0", "react-lowlight": "^3.1.0", - "react-router": "^7.7.1" + "react-router": "^7.9.5", + "react-router-dom": "^7.9.5" }, "devDependencies": { "@react-router/dev": "^7.7.1", @@ -1236,19 +1237,19 @@ } } }, - "node_modules/@react-router/express": { + "node_modules/@react-router/dev/node_modules/@react-router/node": { "version": "7.9.4", - "resolved": "https://registry.npmjs.org/@react-router/express/-/express-7.9.4.tgz", - "integrity": "sha512-qba2YnZXWz8kyXNxXKDa0qS88ct4MwJKMwINmto/LPb08W/YdgRUBSZIw7QnOdN7aFkvWTRGXKBTCcle8WDnRA==", + "resolved": "https://registry.npmjs.org/@react-router/node/-/node-7.9.4.tgz", + "integrity": "sha512-sdeDNRaqAB71BR2hPlhcQbPbrXh8uGJUjLVc+NpRiPsQbv6B8UvIucN4IX9YGVJkw3UxVQBn2vPSwxACAck32Q==", + "dev": true, "license": "MIT", "dependencies": { - "@react-router/node": "7.9.4" + "@mjackson/node-fetch-server": "^0.2.0" }, "engines": { "node": ">=20.0.0" }, "peerDependencies": { - "express": "^4.17.1 || ^5", "react-router": "7.9.4", "typescript": "^5.1.0" }, @@ -1259,9 +1260,9 @@ } }, "node_modules/@react-router/node": { - "version": "7.9.4", - "resolved": "https://registry.npmjs.org/@react-router/node/-/node-7.9.4.tgz", - "integrity": "sha512-sdeDNRaqAB71BR2hPlhcQbPbrXh8uGJUjLVc+NpRiPsQbv6B8UvIucN4IX9YGVJkw3UxVQBn2vPSwxACAck32Q==", + "version": "7.9.5", + "resolved": "https://registry.npmjs.org/@react-router/node/-/node-7.9.5.tgz", + "integrity": "sha512-3mDd32mXh3gEkG0cLPnUaoLkY1pApsTPqn7O1j+P8aLf997uYz5lYDjt33vtMhaotlRM0x+5JziAKtz/76YBpQ==", "license": "MIT", "dependencies": { "@mjackson/node-fetch-server": "^0.2.0" @@ -1270,7 +1271,7 @@ "node": ">=20.0.0" }, "peerDependencies": { - "react-router": "7.9.4", + "react-router": "7.9.5", "typescript": "^5.1.0" }, "peerDependenciesMeta": { @@ -1304,6 +1305,49 @@ "react-router": "7.9.4" } }, + "node_modules/@react-router/serve/node_modules/@react-router/express": { + "version": "7.9.4", + "resolved": "https://registry.npmjs.org/@react-router/express/-/express-7.9.4.tgz", + "integrity": "sha512-qba2YnZXWz8kyXNxXKDa0qS88ct4MwJKMwINmto/LPb08W/YdgRUBSZIw7QnOdN7aFkvWTRGXKBTCcle8WDnRA==", + "license": "MIT", + "dependencies": { + "@react-router/node": "7.9.4" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "express": "^4.17.1 || ^5", + "react-router": "7.9.4", + "typescript": "^5.1.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@react-router/serve/node_modules/@react-router/node": { + "version": "7.9.4", + "resolved": "https://registry.npmjs.org/@react-router/node/-/node-7.9.4.tgz", + "integrity": "sha512-sdeDNRaqAB71BR2hPlhcQbPbrXh8uGJUjLVc+NpRiPsQbv6B8UvIucN4IX9YGVJkw3UxVQBn2vPSwxACAck32Q==", + "license": "MIT", + "dependencies": { + "@mjackson/node-fetch-server": "^0.2.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "react-router": "7.9.4", + "typescript": "^5.1.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, "node_modules/@remix-run/node-fetch-server": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/@remix-run/node-fetch-server/-/node-fetch-server-0.9.0.tgz", @@ -9482,9 +9526,9 @@ } }, "node_modules/react-router": { - "version": "7.9.4", - "resolved": "https://registry.npmjs.org/react-router/-/react-router-7.9.4.tgz", - "integrity": "sha512-SD3G8HKviFHg9xj7dNODUKDFgpG4xqD5nhyd0mYoB5iISepuZAvzSr8ywxgxKJ52yRzf/HWtVHc9AWwoTbljvA==", + "version": "7.9.5", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-7.9.5.tgz", + "integrity": "sha512-JmxqrnBZ6E9hWmf02jzNn9Jm3UqyeimyiwzD69NjxGySG6lIz/1LVPsoTCwN7NBX2XjCEa1LIX5EMz1j2b6u6A==", "license": "MIT", "dependencies": { "cookie": "^1.0.1", @@ -9503,6 +9547,22 @@ } } }, + "node_modules/react-router-dom": { + "version": "7.9.5", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.9.5.tgz", + "integrity": "sha512-mkEmq/K8tKN63Ae2M7Xgz3c9l9YNbY+NHH6NNeUmLA3kDkhKXRsNb/ZpxaEunvGo2/3YXdk5EJU3Hxp3ocaBPw==", + "license": "MIT", + "dependencies": { + "react-router": "7.9.5" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "react": ">=18", + "react-dom": ">=18" + } + }, "node_modules/react-router/node_modules/cookie": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/cookie/-/cookie-1.0.2.tgz", diff --git a/package.json b/package.json index 881562e..b9c5601 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,8 @@ "react": "^19.1.0", "react-dom": "^19.1.0", "react-lowlight": "^3.1.0", - "react-router": "^7.7.1" + "react-router": "^7.9.5", + "react-router-dom": "^7.9.5" }, "devDependencies": { "@react-router/dev": "^7.7.1",