Skip to content

Commit

Permalink
Reorganize client and server modules. Add temporary music for client.
Browse files Browse the repository at this point in the history
  • Loading branch information
nmcalabroso committed Mar 24, 2014
1 parent 5cd839b commit 2255ff4
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pyc
Binary file added assets/sfx/ost.mp3
Binary file not shown.
Empty file added client/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
13 changes: 11 additions & 2 deletions game/manager.py → client/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@ def __init__(self,*args,**kwargs):
self.game_objects = [] #gameobject pool
self.widgets = [] #gui pool
self.labels = [] #label pool
self.audio = None

self.window = None
self.active = True
self.visible = False

self.state = Resources.states['TITLE']
self.focus = None
self.set_focus(self.find_widget('text_ip'))
self.my_connection = Connection()

#State transitions
def switch_to_setup(self,batch):
bg = self.find_widget('my_bg')
bg.set_image(Resources.sprites['setup_bg'])
Expand Down Expand Up @@ -60,9 +64,12 @@ def set_player_data(self):
text_port = self.find_widget('text_port')
text_name = self.find_widget('text_name')

ip_address = '127.0.0.1'#text_ip.document.text
port_num = 8080#int(text_port.document.text)
#ip_address = '127.0.0.1'#text_ip.document.text
#port_num = 8080#int(text_port.document.text)
ip_address = text_ip.text
port_num = text_port.text
name = text_name.document.text

self.my_connection.connect_client((ip_address,port_num))

#attributes
Expand Down Expand Up @@ -103,6 +110,7 @@ def set_player_data(self):
def switch_to_end(self):
pass

#Utilities
def set_player_names(self):
pass

Expand Down Expand Up @@ -262,6 +270,7 @@ def delete_widgets_by_batch(self,batch):
def on_mouse_motion(self,x,y,dx,dy):
self.window.set_mouse_cursor(None)

#Game Logic
def update(self,dt):
if self.state == Resources.states['GAME']:
player_attr = self.my_connection.receive_message()
Expand Down
4 changes: 4 additions & 0 deletions game_push.py → client_push.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

my_bg = Background(name = 'my_bg',
img = Resources.sprites['title_bg'])
my_music = Resources.audio['ost']

@game_window.event
def on_draw():
Expand Down Expand Up @@ -57,6 +58,8 @@ def update(dt):

#<-- States -->
def title_screen():
my_music.play()

# Instantiation section #
play_button = Button(name = 'start_button',
curr_state = 'TITLE',
Expand Down Expand Up @@ -269,6 +272,7 @@ def main():
game_screen()
end_screen()

manager.audio = my_music
manager.add_widget(my_bg)
game_window.push_handlers(manager)
#Pyglet Settings
Expand Down
7 changes: 7 additions & 0 deletions game/resources.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pyglet.graphics import Batch
from pyglet import image
from pyglet import media
from pyglet import window
from os.path import join

Expand Down Expand Up @@ -41,6 +42,12 @@ class Resources:
# End of Batches

# Declare all of your assets here #
audio = {}
sfx_path = './assets/sfx'

#Sound Effects
audio['ost'] = media.load(join(sfx_path,"ost.mp3"))

sprites = {}
res_path = './assets/img'

Expand Down
Binary file modified game/resources.pyc
Binary file not shown.

0 comments on commit 2255ff4

Please sign in to comment.