1. Home
  2. /
  3. Panda3d
  4. /
  5. Mouse-Following Sprite

Mouse-Following Sprite - Panda3d Typing CST Test

Loading…

Mouse-Following Sprite — Panda3d Code

A 2D sprite follows the mouse position.

from direct.showbase.ShowBase import ShowBase
from direct.gui.OnscreenImage import OnscreenImage

class MouseFollow(ShowBase):
	def __init__(self):
		ShowBase.__init__(self)
		self.cursor = OnscreenImage(image='cursor.png', pos=(0,0,0), scale=0.1)
		self.taskMgr.add(self.update, 'follow')

	def update(self, task):
		if self.mouseWatcherNode.hasMouse():
		x = self.mouseWatcherNode.getMouseX()
		y = self.mouseWatcherNode.getMouseY()
		self.cursor.setPos(x, 0, y)
		return task.cont

app = MouseFollow()
app.run()

Panda3d Language Guide

Panda3D is an open-source, cross-platform game engine primarily for Python and C++ that supports 3D rendering, physics, audio, input, networking, and VR/AR applications. It is designed for both educational and commercial projects, with a focus on rapid prototyping and full-featured 3D game development.

Primary Use Cases

  • ▸3D games (desktop and mobile)
  • ▸Educational simulations and VR apps
  • ▸Visualization tools and interactive media
  • ▸Prototyping 3D environments
  • ▸Research and AI simulation

Notable Features

  • ▸Full Python integration for rapid development
  • ▸Scene graph-based 3D engine
  • ▸Shader and lighting support
  • ▸Physics integration (Bullet, ODE)
  • ▸Cross-platform deployment (Windows, macOS, Linux)

Origin & Creator

Panda3D was originally developed by Disney’s VR studio for their massively multiplayer online game projects and released publicly in 2002. It is maintained by the community and Carnegie Mellon University’s Entertainment Technology Center.

Industrial Note

Panda3D is favored in academia, research, and educational projects, as well as indie 3D game development and simulations that require Python-first rapid prototyping and extensive customization.

More Panda3d Typing Exercises

Panda3D Keyboard Movement BoxPanda3D Rotating CubePanda3D Change Color on ClickPanda3D Simple Jumping ObjectPanda3D 3D Camera OrbitPanda3D Toggle VisibilityPanda3D Spin On Key HoldPanda3D Resize ModelPanda3D Auto Forward Motion

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher