1. Home
  2. /
  3. Pixijs
  4. /
  5. Random Movement

Random Movement - Pixijs Typing CST Test

Loading…

Random Movement — Pixijs Code

Sprite moves randomly on the screen.

# pixijs/demo/random_movement.html
<html>
	<head>
		<script src="https://cdnjs.cloudflare.com/ajax/libs/pixi.js/7.2.4/pixi.min.js"></script>
	</head>
	<body>
		<script>
		const app = new PIXI.Application({ width: 800, height: 600 });
		document.body.appendChild(app.view);

		const sprite = PIXI.Sprite.from('https://pixijs.io/examples/examples/assets/bunny.png');
		sprite.anchor.set(0.5);
		app.stage.addChild(sprite);

		app.ticker.add(() => {
		sprite.x += (Math.random()-0.5)*5;
		sprite.y += (Math.random()-0.5)*5;
		});
		</script>
	</body>
</html>

Pixijs Language Guide

PixiJS is a fast, 2D rendering JavaScript library that leverages WebGL (with canvas fallback) to create interactive graphics, games, and applications for the web. It offers a high-performance API for sprites, textures, filters, and animations.

Primary Use Cases

  • ▸2D game development for web and mobile
  • ▸Interactive web applications and dashboards
  • ▸Animated banners and marketing content
  • ▸Data visualization with GPU acceleration
  • ▸Integration with other JS animation libraries (GSAP, Anime.js)

Notable Features

  • ▸GPU-accelerated rendering via WebGL
  • ▸Automatic Canvas fallback for legacy devices
  • ▸Efficient sprite batching and texture management
  • ▸Filter and shader support
  • ▸Animation ticker and interaction handling

Origin & Creator

PixiJS was created by Mat Groves in 2013 and is maintained by the PixiJS team and community contributors.

Industrial Note

PixiJS is widely used in 2D web games, interactive experiences, data visualizations, advertising banners, HTML5 games, and creative web apps requiring fast, GPU-accelerated rendering.

More Pixijs Typing Exercises

Simple PixiJS ScenePixiJS Moving SpritePixiJS Scaling SpritePixiJS Multiple SpritesPixiJS Interactive SpritePixiJS Draggable SpritePixiJS Scale and RotatePixiJS Follow Path

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher