mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 16:20:11 -04:00
Lint asteroids sample
This commit is contained in:
parent
18e8918138
commit
0a8e401f3a
@ -13,16 +13,17 @@
|
|||||||
# most games so it seemed appropriate to show what a full game in Panda
|
# most games so it seemed appropriate to show what a full game in Panda
|
||||||
# could look like.
|
# could look like.
|
||||||
|
|
||||||
from direct.showbase.ShowBase import ShowBase
|
|
||||||
from panda3d.core import TextNode, TransparencyAttrib
|
|
||||||
from panda3d.core import LPoint3, LVector3
|
|
||||||
from direct.gui.OnscreenText import OnscreenText
|
|
||||||
from direct.task.Task import Task
|
|
||||||
from math import sin, cos, pi
|
from math import sin, cos, pi
|
||||||
from random import randint, choice, random
|
from random import randint, choice, random
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from direct.gui.OnscreenText import OnscreenText
|
||||||
from direct.interval.MetaInterval import Sequence
|
from direct.interval.MetaInterval import Sequence
|
||||||
from direct.interval.FunctionInterval import Wait, Func
|
from direct.interval.FunctionInterval import Wait, Func
|
||||||
import sys
|
from direct.showbase.ShowBase import ShowBase
|
||||||
|
from direct.task.Task import Task
|
||||||
|
from panda3d.core import TextNode, TransparencyAttrib
|
||||||
|
from panda3d.core import LPoint3, LVector3
|
||||||
|
|
||||||
# Constants that will control the behavior of the game. It is good to
|
# Constants that will control the behavior of the game. It is good to
|
||||||
# group constants like this so that they can be changed once without
|
# group constants like this so that they can be changed once without
|
||||||
@ -53,8 +54,8 @@ def loadObject(tex=None, pos=LPoint3(0, 0), depth=SPRITE_POS, scale=1,
|
|||||||
transparency=True):
|
transparency=True):
|
||||||
# Every object uses the plane model and is parented to the camera
|
# Every object uses the plane model and is parented to the camera
|
||||||
# so that it faces the screen.
|
# so that it faces the screen.
|
||||||
obj = loader.loadModel("models/plane")
|
obj = base.loader.loadModel("models/plane")
|
||||||
obj.reparentTo(camera)
|
obj.reparentTo(base.camera)
|
||||||
|
|
||||||
# Set the initial position and scale.
|
# Set the initial position and scale.
|
||||||
obj.setPos(pos.getX(), depth, pos.getY())
|
obj.setPos(pos.getX(), depth, pos.getY())
|
||||||
@ -71,7 +72,7 @@ def loadObject(tex=None, pos=LPoint3(0, 0), depth=SPRITE_POS, scale=1,
|
|||||||
|
|
||||||
if tex:
|
if tex:
|
||||||
# Load and set the requested texture.
|
# Load and set the requested texture.
|
||||||
tex = loader.loadTexture("textures/" + tex)
|
tex = base.loader.loadTexture("textures/" + tex)
|
||||||
obj.setTexture(tex, 1)
|
obj.setTexture(tex, 1)
|
||||||
|
|
||||||
return obj
|
return obj
|
||||||
@ -135,7 +136,7 @@ class AsteroidsDemo(ShowBase):
|
|||||||
# The first argument is the function to be called, and the second
|
# The first argument is the function to be called, and the second
|
||||||
# argument is the name for the task. It returns a task object which
|
# argument is the name for the task. It returns a task object which
|
||||||
# is passed to the function each frame.
|
# is passed to the function each frame.
|
||||||
self.gameTask = taskMgr.add(self.gameLoop, "gameLoop")
|
self.gameTask = base.taskMgr.add(self.gameLoop, "gameLoop")
|
||||||
|
|
||||||
# Stores the time at which the next bullet may be fired.
|
# Stores the time at which the next bullet may be fired.
|
||||||
self.nextBullet = 0.0
|
self.nextBullet = 0.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user