-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add one game character when hosting a game.
- Loading branch information
1 parent
08ba138
commit dd2285a
Showing
16 changed files
with
94 additions
and
11 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
import socket | ||
|
||
class Connection: | ||
def __init__(self): | ||
self.my_socket = socket.socket() | ||
|
||
def host_server(self): | ||
pass | ||
|
||
def join_server(self,configs): | ||
pass | ||
|
||
def send_message(self,message): | ||
pass | ||
|
||
def receive_message(self,message): | ||
def receive_message(self): | ||
pass |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,56 @@ | ||
from gameobject import GameObject | ||
from pyglet.window import key | ||
|
||
class Player(GameObject): | ||
def __init__(self,actual_name,name,*args,**kwargs): | ||
super(Player,self).__init__(name = name,*args,**kwargs) | ||
self.actual_name = actual_name | ||
self.actual_name = actual_name | ||
self.velocity_x = 3 | ||
self.velocity_y = 3 | ||
self.keys = {} | ||
self.keys['up'] = False | ||
self.keys['down'] = False | ||
self.keys['right'] = False | ||
self.keys['left'] = False | ||
|
||
def is_colliding(self,x,y): | ||
if x > (self.x - (self.width*0.5)) and x < (self.x + (self.width*0.5)): | ||
if y > (self.y - self.height*0.5) and y < (self.y + (self.height*0.5)): | ||
return True | ||
return False | ||
|
||
def set_velocity(self,velocity_x = 1, velocity_y = 1): | ||
self.velocity_x = velocity_x | ||
self.velocity_y = velocity_y | ||
|
||
def on_key_press(self,symbol,modifiers): | ||
if symbol == key.LEFT: | ||
self.keys['left'] = True | ||
elif symbol == key.UP: | ||
self.keys['up'] = True | ||
elif symbol == key.RIGHT: | ||
self.keys['right'] = True | ||
elif symbol == key.DOWN: | ||
self.keys['down'] = True | ||
|
||
def on_key_release(self,symbol,modifiers): | ||
if symbol == key.LEFT: | ||
self.keys['left'] = False | ||
elif symbol == key.UP: | ||
self.keys['up'] = False | ||
elif symbol == key.RIGHT: | ||
self.keys['right'] = False | ||
elif symbol == key.DOWN: | ||
self.keys['down'] = False | ||
|
||
def update(self,dt): | ||
if self.keys['left']: | ||
self.x -= self.velocity_x | ||
elif self.keys['up']: | ||
self.y += self.velocity_y | ||
elif self.keys['right']: | ||
self.x += self.velocity_x | ||
elif self.keys['down']: | ||
self.y -= self.velocity_y | ||
|
||
print "x,y",(self.x,self.y) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters