Im not sure how to describe it but whenever something moves it vibrates as if my bullet task and other tasks were out of sync or something. heres a link to all my code since ive no clue whats causing it and its easier to see when you run it. wasd move, f1 bullet debug, esc menu. I feel like its something to do with the tasks or maybe the bullet task is out of sync with my other tasks. code - dl.dropbox.com/u/22568676/VoxelDash.rar (its a ninja ide workstation, i dont think you can import it as a pydev project D: )
seeing as people prolly dont wanna dl my source ive at leats narrowed it down to these 2 classes
##############################################
# #IMPORT# #
##############################################
from pandac.PandaModules import Mat4
from direct.gui.DirectGui import *
##############################################
# #External Class IMPORT# #
##############################################
from Menu import *
##############################################
# #NEW CLASS# #
##############################################
class ControlHandler():
fsmState = True
def __init__(self, update, bulletDebugNode, camera, windowProps, player):
#args
self.update = update
self.debugNP = bulletDebugNode
self.camera = camera
self.cameraTask = camera.thisTask
self.wp = windowProps
self.player = player
self.createControls()
self.singleSM(self.pauseGame, self.resumeGame)
def singleSM(self, onFunction, offFunction):
'''"Single State Machine"
Takes two methods as args, runs onFunction
when self.fsmState = False(Default state),
runs offFunction when self.fsmState = True'''
if self.fsmState:
self.fsmState = False
offFunction()
else:
self.fsmState = True
onFunction()
def escMenu(self):
'''Runs functions when escape is pressed'''
self.singleSM(self.pauseGame, self.resumeGame)
def pauseGame(self):
'''Pauses the game by removing any taskmgr'''
self.wp.setCursorHidden(False)
base.win.requestProperties(self.wp)
mat = Mat4(camera.getMat())
mat.invertInPlace()
base.mouseInterfaceNode.setMat(mat)
base.enableMouse()
self.menu = Menu(self.escMenu)
taskMgr.remove('update')
taskMgr.remove("cameraUpdate")
#taskMgr.remove("inputTask")
self.menu.loadPauseMenu()
def resumeGame(self):
self.wp.setCursorHidden(True)
base.win.requestProperties(self.wp)
try:
self.menu.destroyAllMenus()
except AttributeError:
print("Nothing to destroy!")
taskMgr.add(self.update, 'update')
self.camera.beginTask()
#self.player.beginTask()
base.disableMouse()
def debugBullet(self):
if self.debugNP.isHidden():
self.debugNP.show()
else:
self.debugNP.hide()
def createControls(self):
#Sets up the controls
base.accept("escape", self.escMenu)
base.accept("f1", self.debugBullet)
##############################################
# #IMPORT# #
##############################################
from direct.task.Task import Task
from direct.task.TaskManagerGlobal import taskMgr
##############################################
# #External Class IMPORT# #
##############################################
##############################################
# #NEW CLASS# #
##############################################
class Camera():
def __init__(self, nodeToFollow):
self.np = nodeToFollow
self.attachCamera()
self.thisTask = Task(self.updateCamera)
def beginTask(self):
taskMgr.add(self.thisTask, "cameraUpdate", extraArgs=[self])
def attachCamera(self):
self.cn = render.attachNewNode('cameraNode')
base.camera.reparentTo(self.cn)
base.camera.setPos(0, -10, 10)
base.camera.lookAt(self.np)
def updateCamera(task, self):
self.cn.setPos(self.np.getPos())
self.cn.setH(self.np.getH())
#base.camera.lookAt(self.np)
pointer = base.win.getPointer(0)
pointerX = pointer.getX()
pointerY = pointer.getY()
if base.win.movePointer(0, base.win.getXSize()/2, base.win.getYSize()/2):
self.Pitch = -((pointerY - base.win.getYSize()/2)*.1)
self.Heading = -((pointerX - base.win.getXSize()/2)*.1)
self.cn.setP(self.cn, self.Pitch)
#self.cn.setH(self.np.getH())
self.np.setH(self.np, self.Heading)
print(self.Heading)
print(self.np.getH())
print(self.cn.getH())
return Task.cont
[/quote]