I am using Python and wxPython to attempt to make a 2d game. When w is pressed, the tiles (except the character) should move so it looks like you are moving. The problem is, when the key is pressed, nothing moves. I added a line of code(no longer there) to make sure the tile position variable was changing, which it was. So, the position is not updating. Is there a way to reload the frame?
import wx
level=1
attack=1
defense=1
health=5
map4_31_locationx=270
map4_31_locationy=170
class MainWindow(wx.Frame):
def __init__(self):
wx.Frame.__init__(self,None,-1,size = (600, 400))
self.panel = wx.Panel(self,-1)
self.map4_31="C:/python27/game/4_31.gif"
self.map1=wx.Image(self.map4_31,wx.BITMAP_TYPE_GIF).ConvertToBitmap()
height=self.map1.GetHeight()
width=self.map1.GetWidth()
self.map1.map4_31 = wx.StaticBitmap(self.panel, -1, self.map1, (map4_31_locationx, map4_31_locationy), (width,height))
self.playerFile = "C:/python27/game/player_tile.gif"
self.playerbmp = wx.Image(self.playerFile,wx.BITMAP_TYPE_GIF).ConvertToBitmap()
height=self.playerbmp.GetHeight()
width=self.playerbmp.GetWidth()
self.playerbmp.playerbitmap = wx.StaticBitmap(self.panel, -1, self.playerbmp, (270,170), (width,height))
self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPress)
self.Center()
def moveup(self):
global map4_31_locationy
map4_31_locationy-=30
def OnKeyPress(self,event):
keycode=event.GetKeyCode()
print keycode
if keycode==87:
MainWindow().moveup()
while True:
app = wx.PySimpleApp()
MainWindow().Show()
app.MainLoop()