initial commit
This commit is contained in:
		
							
								
								
									
										50
									
								
								client/src/main.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								client/src/main.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,50 @@
 | 
			
		||||
import { Application, Assets, Sprite } from "pixi.js";
 | 
			
		||||
import { Hand } from "./hand";
 | 
			
		||||
 | 
			
		||||
(async () => {
 | 
			
		||||
	// Create a new application
 | 
			
		||||
	const app = new Application();
 | 
			
		||||
 | 
			
		||||
	// Initialize the application
 | 
			
		||||
	await app.init({ background: "#1099bb", resizeTo: window });
 | 
			
		||||
 | 
			
		||||
	// Append the application canvas to the document body
 | 
			
		||||
	document.getElementById("pixi-container")!.appendChild(app.canvas);
 | 
			
		||||
 | 
			
		||||
	try {
 | 
			
		||||
		// Create the SpriteSheet from data and image
 | 
			
		||||
		const cards = await Assets.load("/public/assets/cards.json");
 | 
			
		||||
 | 
			
		||||
		console.log(cards);
 | 
			
		||||
 | 
			
		||||
		// Create a bunny Sprite
 | 
			
		||||
		const bunny = new Sprite(cards.textures["fourOfHearts"]);
 | 
			
		||||
 | 
			
		||||
		console.log(bunny);
 | 
			
		||||
 | 
			
		||||
		// Center the sprite's anchor point
 | 
			
		||||
		bunny.anchor.set(0.5);
 | 
			
		||||
 | 
			
		||||
		// Move the sprite to the center of the screen
 | 
			
		||||
		bunny.position.set(app.screen.width / 2, app.screen.height / 2);
 | 
			
		||||
 | 
			
		||||
		bunny.height /= 1.5;
 | 
			
		||||
		bunny.width /= 1.5;
 | 
			
		||||
 | 
			
		||||
		// Add the bunny to the stage
 | 
			
		||||
		// app.stage.addChild(bunny);
 | 
			
		||||
 | 
			
		||||
		const hand = new Hand(["fourOfDiamonds"]);
 | 
			
		||||
		app.stage.addChild(hand.cards);
 | 
			
		||||
 | 
			
		||||
		// Listen for animate update
 | 
			
		||||
		// app.ticker.add((time) => {
 | 
			
		||||
		// 	// Just for fun, let's rotate mr rabbit a little.
 | 
			
		||||
		// 	// * Delta is 1 if running at 100% performance *
 | 
			
		||||
		// 	// * Creates frame-independent transformation *
 | 
			
		||||
		// 	bunny.rotation += 0.1 * time.deltaTime;
 | 
			
		||||
		// });
 | 
			
		||||
	} catch (err) {
 | 
			
		||||
		console.log(err);
 | 
			
		||||
	}
 | 
			
		||||
})();
 | 
			
		||||
		Reference in New Issue
	
	Block a user