View Single Post
XxMoNsTeRXM

JCF Member

Joined: Sep 2013

Posts: 191

XxMoNsTeRXM is doing well so far

Nov 2, 2014, 12:20 AM
XxMoNsTeRXM is offline
Reply With Quote
Yay... I am so proud of myself, I made a gem-saving system. Because when you die in a bottom pit, you lose all your gems, so... as the gems do not respawn, I made a gem-saving system.


This image also shows the theme of my level.

Here's the code for everyone who has a bottom pit in the level and wants the gems saved:
Code:
array savedgems(3, 0);
bool access = true;

void onPlayer(jjPLAYER@ p) {
  switch(p.health) {
  case 0:
  if (access) {
   savedgems[0] = p.gems[GEM::RED];
   savedgems[1] = p.gems[GEM::GREEN];
   savedgems[2] = p.gems[GEM::BLUE];
   jjAlert("Red gems current: " + p.gems[GEM::RED]);
   jjAlert("|Red gems saved: " + savedgems[0]);
   jjAlert("Green gems current: " + p.gems[GEM::GREEN]);
   jjAlert("|Green gems saved: " + savedgems[1]);
   jjAlert("Blue gems current: " + p.gems[GEM::BLUE]);
   jjAlert("|Blue gems saved: " + savedgems[2]);
   access = false;
  }
  break;
  case 5:
   p.gems[GEM::RED] = savedgems[0];
   jjAlert("||Red gems loaded: " + p.gems[GEM::RED]);
   p.gems[GEM::GREEN] = savedgems[1];
   jjAlert("||Green gems loaded: " + p.gems[GEM::GREEN]);
   p.gems[GEM::BLUE] = savedgems[2];
   jjAlert("||Blue gems loaded: " + p.gems[GEM::BLUE]);
   if (!access) access = true;
   p.health = 4;
   break;
 }
}

The code does work!

Last edited by XxMoNsTeRXM; Nov 5, 2014 at 04:05 AM.