Multiplayer Updates 2


  • Have moved a number of the client's update functions so they're solely carried out in the server. This includes most collisions (haven't done shield collisions yet) and scoring/lives.
  • Added large number of protocols:
    • Movement in one client is now broadcasted through the server class to all of the other clients. Same for the clients shooting. A clientmap was added to the client class so that all the other clients can be stored in a similar way that they are in the server. Moving players that are not the active player for the client works in a similar way to the server- a vx is stored and used in the update for the player.
    • Losing lives and scores is also carried out in the server and broadcasted to the clients. When there's an update for one player, the change is stored in the clientmap and is also sent to the items in the clientmaps of all the clients. This is used to update the text onscreen.
    • Enemy bullets are now synched up based on the enemy chosen to fire in the server update. The update function in the enemy controller was split into a server update and a client update, the latter of which doesn't have the enemies fire. Instead, the number of the enemy that fires is saved and sent in the message to the clients. Then an independent fire function is called by the client. No collision happens in the clients, the bullet is simply deleted when/if a message is received from the server that the player lost a life. Otherwise it flies offscreen.
    • Enemies being hit is carried out similarly, with the index of the enemy being sent to the client to delete.
  • Still need to sync the movement of the enemy block across clients, sync up creation of UFOS and move shield collision to the server.

Multiplayer updates

Server-client message sending:
-add protocol w/unique hex identifier
-send message to server from client with string body/proto id and parse using switch statement/message type
-same in reverse
-need to add client ids to map with velocity, color, etc
-change self.vx and self.fire in the server file once map is set up


  • Split server and client into separate files. Both inherit from scgame, and server has several scgame functions overriden in it that remove player creation, etc.
  • Server calls a function that adds a player to its game when a new client is added/greet message is received. It also adds a new client id with a color/velocity/fire boolean to a map that can be referenced later.
  • When movement happens in a client player, a proto message is sent to the server that holds the velocity, which is applied to the player with the id of that client. Then, in the update for the player, the player's velocity is changed to the velocity stored in the map.
  • Have changed the message sending so that messages are only sent once when velocity changes to limit lag.
  • Shooting works similarly and sets/sends a boolean when the player in the server version needs to fire.

Work for Monday 7/10


  • Added score on game over page.
  • Added sound for game over and level finish.
  • Changed font size for score so it stops going off-screen.
  • Added second player controlled by WASD keys (shoot with W) that scores and has lives independently.
  • Time: 3 hours
Total time for single-player, including Monday: 93.5 hours (not sure if this is right so you might want to check yourself)

Work for Friday 7/7


  • Added sprites/sprite changes for shields when hit
  • Updated SDL
  • Installed SDL_mixer and added sound for shooting, hitting an enemy, ufo appearance, losing a life and enemy movement
  • Time: 4 hours

Work for Wednesday 7/5 and Thursday 7/6

Wednesday:

  • Changed sprite drawer so it works
  • Split Drawable class into two separate subclasses, one for drawing a rectangle and the other being an image sprite drawer
  • Associated sprite with player ship
  • Encountered error where collision was off
  • Time: 4 hours
Thursday:
  • Added get functions to drawable subclasses and fixed collision
  • Added sprites to enemies and adjusted spacing accordingly
  • Fixed UFO so that it would reappear after being shot
  • Added sprite to UFO and changed code appropriately
  • Changed fire rate of player to be based on time- able to fire every .5 seconds, not sure if this is good (can test), also changed enemy movement to be time based
  • Time: 4 hours

Work for Friday 6/30


  • Created random UFO enemies.
    • Fly across top of screen (gif has higher appearance rate for sake of recording)
    • Worth 100 points
    • Basically the same code-wise as enemies but with less functions (no shooting, etc)
    • Randomly picks a side to come from
Time: 3 hours

Work for Thursday 6/29


  • Added game over condition when enemies reach player.
  • Added sprite drawing system.
  • Encountered problem where nothing is showing when I try to load the sprite for the player. It is rendering and the player position is changing, but I'm not sure what I'm supposed to be setting the call equal to. If I do player.sprite = the call to the sprite drawer, that causes an error. 
  • Time: 4 hours

Work for Wednesday 6/28


  • Working on fixing a bug where if the most far-left row of enemies is completely destroyed the enemy movement is screwed up.
  • Couldn't quite figure out how to fix this but the reset is now working. Will work on it later. It's not extremely vital at the moment as opposed to getting the game to actually work, but is annoying as I am testing with only one row of enemies and I'm being forced to destroy the far left one last every time.
  • Sped up movement per level works!
  • Now need to fix movement of enemies as testing has revealed errors.
  • Fixed movement of enemies by changing the update function from updating the left side of the box based on the first enemy in the list every time to just adding the number that Enemy.vx changes by.
  • Other tweaks:
    • Changed shields to be smaller
    • Lowered fire rate of enemies
Total time: 4 hours

Work for Tuesday 6/27


  • Moved enemy creation into the enemyblock class, which was renamed enemycontroller. Enemy creation method is called in the init method of enemycontroller. Enemycontroller now holds enemy list, which is accessed in update.
  • Created reset method in enemycontroller, which clears the list and then makes a new one.
  • Encountering errors, most likely due to the location where I'm calling the reset method.
  • Total Time: 3 hours

Work for Friday 6/23


  • Added shields in.
  • Not sure how big they needed to be, but can change easily.
  • Currently take 5 hits to destroy and instead of changing sprite, they change color with hits.
Time: 3 hours
Total Time: 16 hours

Work for next week will probably mostly be trying to set up a level system, since that seems like a pain.

Work for Thursday 6/22


  • Added position parameter to textMaker class so that text can be placed on screen.
  • Added score system to enemies so that they're worth different amounts.
  • Added updateScore class to ui.py so that score can be updated onscreen in the same way lives can
  • Added screen that says game over before game ends
  • Couldn't implement onscreen FPS counter in the way that it's written in ttf.py because it relies too heavily on world/sdl2.ext classes that use world. Not sure if there's another better way to do this.
  • Working on level system:
    • When enemies is empty, the game needs to display that the level was beaten, reset the enemies and player, don't reset lives and score, and increase the speed of the enemies.
    • Wrote reset function that's basically just the same thing as creating the sprites, but saved lives and score from the player. Not sure where to put it in the code so that it can continue to update correctly.
  • Time: 3 hours 

Work for Wednesday 6/21


  • Finally got text working after 18 years. Realized after setting up different text system based on file sent to me that I wasn't initiating TTF correctly. Now works. Will need to add position parameter later so that I can place the rectangle where the text is.
  • For now, created class that updates lives specifically so that the lives of the player can update and run it. Created update function in class that changes lives without needing to run the renderer in every time.
  • Will probably also change font later and move it so it isn't right up against the edge. Tomorrow will work on score and game over screen.
  • Time: 4 hours


Work for Tuesday 6/20


  • Install commands: 
    • cd Downloads
    • tar xvzf SDL2_ttf-2.0.14.tar.gz 
    • cd SDL2_ttf-2.0.14
    • ls
    • pwd  
    • sudo su
    • [then type in your normal user password to log into your mac]
    • ./configure
    • make install
  • Achieved nothing today. Tried to get sprites working again to no avail. Eventually got it to the point where no errors are coming up, but still showing black screen. Not sure if they're actually rendering or not.
  • If I have it print the type of the variable sprite when it uses the drawable method, it does say they're texturesprites. Positions also appear to be changing when I fire bullets, etc. Still, nothing is showing onscreen.
  • Time: 4 hours