View Single Post
  #7  
Old 09-02-2008, 04:49 PM
Kristi Kristi is offline
Bowie's Deciple
Kristi's Avatar
Join Date: Dec 2003
Location: Boston, MA
Posts: 748
Kristi has a spectacular aura aboutKristi has a spectacular aura about
Send a message via AIM to Kristi Send a message via MSN to Kristi
Umm... serverside code for this Sid? Terrible, and CBK might be complicating things too much.

Logical steps people
Things we need to do:
- Init things
- timeout start
- Spawn a spike?
--- Random check for spike
--- Check to see if the spawning rate should change
- update spike positions
- check for player collisions
--- do what happens when player collides.
- timeout

PHP Code:
//#CLIENTSIDE

// ================ Events ===================

function onCreated() {
  
init();
  
onTimeout();
}

//====================

function onTimeout() {
  if(
checkSpawnSpike(this.spawnRate)) {
    
this.spikes.add(spawnSpike());
  }
  for (
temp.sthis.spikes) {
    
temp.s.updateSpikePos();
    if(
temp.s.checkPlayerCollision()) {
      
doPlayerDamage();
    }
  }
  
setTimer(.05);
}

// ============= ! End Events ====================

// ========== User Defined Functions ===============

function init() {
  
// init values here
  // for example: the starting rate of spikes
}

//=====================

function checkSpawnRate() {
  
// return true if should spawn a spike
  // false is not
  // (maybe use random? :D)
}

//=======================

function spawnSpike() {
  
// Return an object with the spike's properties & functions
  // Functions include 
  // updateSpikePos() 
  //   - change the spike's coordinates
  //   - change where the spike visually is.
  // checkPlayerCollision()
  //   - most likely a check to see if an isosceles triangle (spike) 
  //     is colliding with a rectangle (player)
  //     return true if is and false otherwise
}

//====================

function doPlayerDamage() {
  
// What happens when a player actually gets hit.
}

// ========== ! User Defined Functions ============= 
__________________
Reply With Quote