Jump to content



0

Advice for improving player vs player base code?


No replies to this topic

#1 SloeGin OFFLINE  

SloeGin

    Space Invader

  • 14 posts
  • Patience is a 1541
  • Location:Connecticut

Posted Wed Feb 13, 2008 6:46 PM

I'm trying to code some groundwork for a game idea. So far I have the following done:
1) Move player0 and player1 around the playfield and fire a missile
2) Player must wait for missile to reach end of playfield before firing again
3) Missiles fire in direction player is facing
4) The sprite for a player changes relative to the direction the player is moving
5) Scroll the playfield when a player tries to move beyond playfield boundaries
6) When a player causes the playfield to scroll, adjust the other player's x/y relative to the playfield
7) If both players are at full opposite ends of the playfield, do not scroll

There's no collision detection or sound and the sprites are purely functional.

How can I simplify my code? Specifically, I'd like to be able to remove the tons of redundancies. Right now I'm doing almost everything twice: once for player0/joy0/missile0, then do the same thing for player1/joy1/missile1. How can I make these into individual subroutines that know which player's attributes to modify?

I feel like I'm way over thinking the "Playfield Magic" section. Any thoughts/advice on a better way to accomplish this?

(edit: changed topic title)
(updated code: added x/y correction for missiles, still not perfect though)

Attached File  pvpbasecode.bas   12.99K   23 downloads
Attached File  pvpbasecode.bin   4K   40 downloads

Edited by SloeGin, Wed Feb 13, 2008 10:17 PM.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users