   Help with school game? SDL(quickCG) rpg
  I am having huge trouble with my ai system...and I think I am surpassing what I know with what I am trying to do...can anyone help me with some code that will make implementing enemies easier??I put "code" tags but that didnt work lol..srry i guess its "source" hereand the part I need help on is getting the enemy part...I cant get more than one on the screen unless they pass through borders...and thats next to uselessheres the specific methods im using for enemies:void drawEnemy(std::string type,int &avX,int &avY,double &enemyX,double &enemyY){if(type=="rabbit"){    drawRect((int)enemyX,(int)enemyY,(int)enemyX+rabbitWidth,(int)enemyY+rabbitHeight,RGB_White);    drawNoPassRectEnemy(avX,avY,enemyX,enemyY,(int)enemyX-1,(int)enemyY-1,(int)enemyX+rabbitWidth+1,(int)enemyY+rabbitHeight+1);    }}void createEnemy(int enemyNumber,std::string type,double tempEnemyX,double tempEnemyY,double &enemyX,double &enemyY,int &itemDropped){ if(enemyDead[enemyNumber]==false)  {  drawEnemy(type,avX,avY,enemyX,enemyY);  }  //sets position    if(enemyStarter==false){  enemyX=tempEnemyX;  enemyY=tempEnemyY;  enemyStarter=true;  }    if(checkForAttack(enemyNumber,type,enemyHealth,enemyX,enemyY)==true)  {enemyHealthMinus++;    }    if(enemyHealthMinus>=rabbitHealth)  {    enemyDead[enemyNumber]=true;    enemyHealthMinus=0;    itemDropped++;    }}bool drawNoPassRectEnemy(int &avX, int &avY, double &enemyX, double &enemyY, int x, int y, int x2, int y2){  //invisible rect//border controlif(avX+avatarWidth>x-avSpeed&&avX<x&&avY<y2&&avY+avatarHeight>y){avX=x-avatarWidth;}if(avX<x2+avSpeed&&avX>x&&avY<y2&&avY+avatarHeight>y){avX=x2;}if(avY>y-avatarHeight-avSpeed&&avY<y2&&avX+avatarWidth>x&&avX<x2){avY=y-avatarHeight-avSpeed;}if(avY<y2+avSpeed&&avY>y&&avX+avatarWidth>x&&avX<x2){avY=y2+avSpeed;}//is avatar close?if((avX==x-avatarWidth||avX==x2||avY==y-avatarHeight-avSpeed||avY==y2+avSpeed)){if(avX+avatarWidth>x-avSpeed&&avX<x2+avSpeed&&avY>y-avatarHeight-avSpeed&&avY<y2+avSpeed){return true;}}else{return false;}  }bool checkForAttack(int enemyNumber,std::string type,int &enemyHealth,double &enemyX,double &enemyY){if(type=="rabbit"){    enemyHealth=3;    activeEnemy="rabbit";   //read mouse  int x, y;   bool lmb, rmb;  getMouseState(x, y,lmb,rmb);if(enemyX<avX){enemyX+=1;}if(enemyX>avX){enemyX-=1;}if(enemyY<avY){enemyY+=1;}if(enemyY>avY){enemyY-=1;}  if(enemyDead[enemyNumber]==false&&enemyX>avX-rabbitWidth*2&&enemyX<avX+avatarWidth+rabbitWidth&&enemyY>avY-rabbitHeight*2&&enemyY<avY+avatarHeight+rabbitHeight)  {  if(getTicks()%37==0)  avatarHealth--;if(avatarHealth<=0)  end();if(x>=enemyX-rabbitWidth&&y>=enemyY-rabbitHeight&&x<=enemyX+rabbitWidth&&y<=enemyY+rabbitHeight)  {    drawCircle(x,y,5,RGB_Red);  if(getTicks()%37==0&&lmb==true){ drawDisk(x,y,5,RGB_Red);enemyHealth-=weapon; }}    }  if(enemyHealth<rabbitHealth){return true;  } else{return false;}  }}And heres where i am calling them:else if(screen==2){stone();//draw house and  //check if near houseif(drawHouse(avX,avY,100,100)==true)  {   nearHouseLvl[1]=true;  }else{nearHouseLvl[1]=false;}    //house menu if(nearHouseLvl[1]==true)  {  menuMakerDoors("Enter the house?",screen,-2,2,"You need the key!",avX,avY);  } createEnemy(1,"rabbit",600,200,EnemyX[1],EnemyY[1],numKeys);  createEnemy(2,"rabbit",100,20,EnemyX[2],EnemyY[2],numKeys);  }and for reference if you need it heres the complete program code:#include "quickcg.cpp"#include "SDL/SDL.h"#include <string>#include <Windows.h>#define RGB_Brown ColorRGB(139, 80, 14)  using namespace QuickCG;  //avatar position X/Y int avX, avY; //enemy position X/Y double enemyX, enemyY; double EnemyX[500]; double EnemyY[500]; bool enemyStarter=false; //enemy stats std::string activeEnemy; int enemyHealth; int enemyWidth=0; int enemyHeight=0; int enemyHealthMinus=0; const int rabbitWidth=10; const int rabbitHeight=10; const int rabbitHealth=3;   //map stats const int NumScrWide=5; const int NumScrHigh=5;  //avatar specs const int avatarWidth=30; const int avatarHeight=30; const int avSpeed=2; int avatarHealth=100; ColorRGB healthColor=RGB_Green;  //interactive scenery set to not near bool nearBoulderLvl[500]; bool nearHouseLvl[500]; //set keys for game to not found bool keyLvl[500]; //set all enemies to not killed bool enemyDead[500]; bool nearKnifeLvlOne=false; bool knifeLvlOne=false; bool shortSwordLvlTwo=false; bool nearShortSwordLvlTwo=false; bool nearHouseExit=false;  //stats info int numKeys=0;  //initialize weapons bool showCursor=true; int weapon=0; //0=unarmed //1=knife //...   //menu info ColorRGB buttonYTextColor=RGB_Red; ColorRGB buttonNColor=RGB_White; ColorRGB buttonNTextColor=RGB_Red; ColorRGB buttonYColor=RGB_White; bool ansMenuYN=true;  //method initializations void drawKey(int x, int y); void grass(); void stone(); void snow(); void createEnemy(int enemyNumber,std::string type,double tempEnemyX,double tempEnemyY,double &enemyX,double &enemyY,int &itemDropped); void drawEnemy(std::string type,int &avX,int &avY,double &enemyX,double &enemyY); bool checkForAttack(int enemyNumber,std::string type,int &enemyHealth,double &enemyX,double &enemyY); bool drawNoPassRect(int &avX, int &avY, double &enemyX, double &enemyY, int x, int y, int x2, int y2,ColorRGB color); bool drawNoPassRect(int &avX, int &avY, double &enemyX, double &enemyY, int x, int y, int x2, int y2); bool drawNoPassRectEnemy(int &avX, int &avY, double &enemyX, double &enemyY, int x, int y, int x2, int y2); void weaponSelector(); //use for obtaining objects void menuMakerObjects(bool &objectToGet,std::string question,std::string yesAnswer,std::string whatToPresent,int &numToChange); //use for entering and exiting places void menuMakerDoors(std::string question,int &screen,int goToThisLevel,int &exitAvXPosition,int &exitAvYPosition); //use for enter/exit with requirement void menuMakerDoors(std::string question,int &screen,int goToThisLevel,int requirement,std::string denialMessage,int &exitAvXPosition,int &exitAvYPosition); void drawKnife(int x, int y); void drawShortSword(int x, int y); bool drawHouse(int &avX,int &avY,int x, int y); int getAvatarX(int x, int y); int getAvatarY(int x, int y); void drawAvatar(int posX, int posY); void ScreenOne(); void ScreenTwo(); void screenTester(int &screen, int &avX, int &avY); /////MAIN!/////////////////////////////////////////////////////////////////////////////////////////////////// int main(int args, char *argv[]){screen(1000, 500, 0, "Tileset Simulation");int x = w / 2, y = h-20 ;int avatarX=x;int avatarY=h/2;//screen selectorint screen=1;while(!done()){   avX=getAvatarX(avatarX,avatarY);avY=getAvatarY(avatarX,avatarY);avatarX=avX;avatarY=avY;screenTester(screen,avatarX,avatarY);//draws charachterdrawAvatar(avX,avY);//draws health   drawRect(w-151,0,w-150+101,7,RGB_Black);   if(avatarHealth>=100){healthColor=RGB_Green;}   else if(avatarHealth<=75&&avatarHealth>=25){healthColor=RGB_Yellow;}   else if(avatarHealth<25){healthColor=RGB_Red;}   drawRect(w-150,1,w-150+avatarHealth,6,healthColor);   if(avatarHealth<100&&getTicks()%137==0){avatarHealth++;} //weapon selectorweaponSelector();//draws equipment//(keys)drawKey(10, 1);print("x", 25, 5, RGB_Red, 0, RGB_Black, 0);print(numKeys, 35, 5, RGB_Yellow, 0, RGB_Black, 0);//no weaponreadKeys();if(keyDown(SDLK_SPACE)){weapon=0;}if(weapon==0){showCursor=true;}if(weapon!=0){showCursor=false;}////(knife)if(knifeLvlOne==true){drawKnife(50,10);}if(shortSwordLvlTwo==true){drawShortSword(65,10);  }//SCREEN DISPLAY NUMBER print(enemyX,0,0,RGB_White,0,RGB_Black,0);//screen drawingredraw(); //menu yes or no handlingif(ansMenuYN==false){sleep();}//clearing screencls();    }}////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void grass(){   drawRect(1,1,w-1,h-1,RGB_Green);} void stone(){   drawRect(1,1,w-1,h-1,RGB_Gray);}void snow(){   drawRect(1,1,w-1,h-1,RGB_White);}void drawEnemy(std::string type,int &avX,int &avY,double &enemyX,double &enemyY){if(type=="rabbit"){    drawRect((int)enemyX,(int)enemyY,(int)enemyX+rabbitWidth,(int)enemyY+rabbitHeight,RGB_White);    drawNoPassRectEnemy(avX,avY,enemyX,enemyY,(int)enemyX-1,(int)enemyY-1,(int)enemyX+rabbitWidth+1,(int)enemyY+rabbitHeight+1);    }}void createEnemy(int enemyNumber,std::string type,double tempEnemyX,double tempEnemyY,double &enemyX,double &enemyY,int &itemDropped){ if(enemyDead[enemyNumber]==false)  {  drawEnemy(type,avX,avY,enemyX,enemyY);  }  //sets position    if(enemyStarter==false){  enemyX=tempEnemyX;  enemyY=tempEnemyY;  enemyStarter=true;  }    if(checkForAttack(enemyNumber,type,enemyHealth,enemyX,enemyY)==true)  {enemyHealthMinus++;    }    if(enemyHealthMinus>=rabbitHealth)  {    enemyDead[enemyNumber]=true;    enemyHealthMinus=0;    itemDropped++;    }}bool drawNoPassRectEnemy(int &avX, int &avY, double &enemyX, double &enemyY, int x, int y, int x2, int y2){  //invisible rect//border controlif(avX+avatarWidth>x-avSpeed&&avX<x&&avY<y2&&avY+avatarHeight>y){avX=x-avatarWidth;}if(avX<x2+avSpeed&&avX>x&&avY<y2&&avY+avatarHeight>y){avX=x2;}if(avY>y-avatarHeight-avSpeed&&avY<y2&&avX+avatarWidth>x&&avX<x2){avY=y-avatarHeight-avSpeed;}if(avY<y2+avSpeed&&avY>y&&avX+avatarWidth>x&&avX<x2){avY=y2+avSpeed;}//is avatar close?if((avX==x-avatarWidth||avX==x2||avY==y-avatarHeight-avSpeed||avY==y2+avSpeed)){if(avX+avatarWidth>x-avSpeed&&avX<x2+avSpeed&&avY>y-avatarHeight-avSpeed&&avY<y2+avSpeed){return true;}}else{return false;}  }bool checkForAttack(int enemyNumber,std::string type,int &enemyHealth,double &enemyX,double &enemyY){if(type=="rabbit"){    enemyHealth=3;    activeEnemy="rabbit";   //read mouse  int x, y;   bool lmb, rmb;  getMouseState(x, y,lmb,rmb);if(enemyX<avX){enemyX+=1;}if(enemyX>avX){enemyX-=1;}if(enemyY<avY){enemyY+=1;}if(enemyY>avY){enemyY-=1;}  if(enemyDead[enemyNumber]==false&&enemyX>avX-rabbitWidth*2&&enemyX<avX+avatarWidth+rabbitWidth&&enemyY>avY-rabbitHeight*2&&enemyY<avY+avatarHeight+rabbitHeight)  {  if(getTicks()%37==0)  avatarHealth--;if(avatarHealth<=0)  end();if(x>=enemyX-rabbitWidth&&y>=enemyY-rabbitHeight&&x<=enemyX+rabbitWidth&&y<=enemyY+rabbitHeight)  {    drawCircle(x,y,5,RGB_Red);  if(getTicks()%37==0&&lmb==true){ drawDisk(x,y,5,RGB_Red);enemyHealth-=weapon; }}    }  if(enemyHealth<rabbitHealth){return true;  } else{return false;}  }}void menuMakerObjects(bool &objectToGet,std::string question,std::string yesAnswer,std::string whatToPresent,int &numToChange){    //read mouse  int x, y;   bool lmb, rmb;  getMouseState(x, y,lmb,rmb);  //read keys  readKeys();   //show "do you want?" menu  if(objectToGet==false){  //where menu box is on screen  int lineX=w/2;  int lineY=0;  //draw menu box  drawRect(lineX,lineY,lineX+80,lineY+100,RGB_Black);  //text handler  int incrementer=0;  int numSpaces=0;  std::string array[100];  for(int i=0;i<=question.length();i++){array=question.substr(i,1);if(array==" "){lineY+=10;lineX=w/2;incrementer=-8;}print(array,lineX+incrementer,lineY,RGB_White,0,RGB_Black,0);incrementer+=8;}  //show buttons  drawRect(w/2+5,75, w/2+30, 95, buttonYColor);  print("Y",w/2+14, 82, buttonYTextColor, 0, RGB_Black, 0);  drawRect(w/2+50,75, w/2+75, 95, buttonNColor);  print("N",w/2+59, 82, buttonNTextColor, 0, RGB_Black, 0);  }    //change button colors  if(x>=w/2+5&&y>=75&&x<=w/2+30&&y<=95){buttonYColor=RGB_Red;buttonYTextColor=RGB_White;}  else{buttonYColor=RGB_White;buttonYTextColor=RGB_Red;}  if(x>=w/2+50&&y>=75&&x<=w/2+75&&y<=95){buttonNColor=RGB_Red;buttonNTextColor=RGB_White;}  else{buttonNColor=RGB_White;buttonNTextColor=RGB_Red;}  //read answer  //if yes  if(((x>=w/2+5&&y>=75&&x<=w/2+30&&y<=95&&lmb==true)||keyDown(SDLK_y))&&objectToGet==false) { objectToGet=true; if(whatToPresent=="knife"){weapon=1;} else if(whatToPresent=="shortSword"){weapon==2;} else if(whatToPresent=="numKeys"){numKeys++;} }  //if no  else if((x>=w/2+50&&y>=75&&x<=w/2+75&&y<=95&&lmb==true)||keyDown(SDLK_n))  {  drawRect(w/2,0,w/2+80,100,RGB_Black);  print("OK", w/2, 0, RGB_White, 0, RGB_Black, 0);  ansMenuYN=false;  }  //present object if(objectToGet==true){ drawRect(w/2,0,w/2+80,100,RGB_Black);  int lineX=w/2;  int lineY=0;  int incrementer=0;  int numSpaces=0;  std::string array2[100];    for(int i=0;i<=yesAnswer.length();i++){array2=yesAnswer.substr(i,1);if(array2==" "){lineY+=10;lineX=w/2;incrementer=-8;}print(array2,lineX+incrementer,lineY,RGB_White,0,RGB_Black,0);incrementer+=8;}ansMenuYN=false; }}void menuMakerDoors(std::string question,int &screen,int goToThisLevel,int &exitAvXPosition,int &exitAvYPosition){    //read mouse  int x, y;   bool lmb, rmb;  getMouseState(x, y,lmb,rmb);  //read keys  readKeys();    //show "enter/exit" menu  int lineX=w/2;  int lineY=0;    //draw menu box  drawRect(lineX,lineY,lineX+80,lineY+100,RGB_Black);  //text handler  int incrementer=0;  int numSpaces=0;  std::string array[100];    for(int i=0;i<=question.length();i++){array=question.substr(i,1);if(array==" "){lineY+=10;lineX=w/2;incrementer=-8;}print(array,lineX+incrementer,lineY,RGB_White,0,RGB_Black,0);incrementer+=8;}  //draws buttons  drawRect(w/2+5,75, w/2+30, 95, buttonYColor);  print("Y",w/2+14, 82, buttonYTextColor, 0, RGB_Black, 0);  drawRect(w/2+50,75, w/2+75, 95, buttonNColor);  print("N",w/2+59, 82, buttonNTextColor, 0, RGB_Black, 0); //change button colors  if(x>=w/2+5&&y>=75&&x<=w/2+30&&y<=95){buttonYColor=RGB_Red;buttonYTextColor=RGB_White;}  else{buttonYColor=RGB_White;buttonYTextColor=RGB_Red;}  if(x>=w/2+50&&y>=75&&x<=w/2+75&&y<=95){buttonNColor=RGB_Red;buttonNTextColor=RGB_White;}  else{buttonNColor=RGB_White;buttonNTextColor=RGB_Red;}  //read answer  //if yes  if((x>=w/2+5&&y>=75&&x<=w/2+30&&y<=95&&lmb==true)||keyDown(SDLK_y)) { screen=goToThisLevel; avX=exitAvXPosition; avY=exitAvYPosition; }  //if no  else if((x>=w/2+50&&y>=75&&x<=w/2+75&&y<=95&&lmb==true)||keyDown(SDLK_n))  {  drawRect(w/2,0,w/2+80,100,RGB_Black);  print("OK", w/2, 0, RGB_White, 0, RGB_Black, 0);  ansMenuYN=false;  }}void menuMakerDoors(std::string question,int &screen,int goToThisLevel,int requirement,std::string denialMessage,int &exitAvXPosition,int &exitAvYPosition){  //read mouse  int x, y;   bool lmb, rmb;  getMouseState(x, y,lmb,rmb);  //read keys  readKeys();  //show "enter/exit" menu  int lineX=w/2;  int lineY=0;    //draw menu box  drawRect(lineX,lineY,lineX+80,lineY+100,RGB_Black);  //text handler  int incrementer=0;  int numSpaces=0;  std::string array[100];    for(int i=0;i<=question.length();i++){array=question.substr(i,1);if(array==" "){lineY+=10;lineX=w/2;incrementer=-8;}print(array,lineX+incrementer,lineY,RGB_White,0,RGB_Black,0);incrementer+=8;}  //draws buttons  drawRect(w/2+5,75, w/2+30, 95, buttonYColor);  print("Y",w/2+14, 82, buttonYTextColor, 0, RGB_Black, 0);  drawRect(w/2+50,75, w/2+75, 95, buttonNColor);  print("N",w/2+59, 82, buttonNTextColor, 0, RGB_Black, 0); //change button colors  if(x>=w/2+5&&y>=75&&x<=w/2+30&&y<=95){buttonYColor=RGB_Red;buttonYTextColor=RGB_White;}  else{buttonYColor=RGB_White;buttonYTextColor=RGB_Red;}  if(x>=w/2+50&&y>=75&&x<=w/2+75&&y<=95){buttonNColor=RGB_Red;buttonNTextColor=RGB_White;}  else{buttonNColor=RGB_White;buttonNTextColor=RGB_Red;}  //read answer  //if yes  if((x>=w/2+5&&y>=75&&x<=w/2+30&&y<=95&&lmb==true)||keyDown(SDLK_y)&&requirement==true) { screen=goToThisLevel; avX=exitAvXPosition; avY=exitAvYPosition; }  else if(numKeys<requirement){  //text handler  drawRect(w/2,0,w/2+80,100,RGB_Black);  int incrementer=0;  int numSpaces=0;  std::string array3[100];    for(int i=0;i<=denialMessage.length();i++){array3=denialMessage.substr(i,1);if(array3==" "){lineY+=10;lineX=w/2;incrementer=-8;}print(array3,lineX+incrementer,lineY,RGB_White,0,RGB_Black,0);incrementer+=8;}  }  //if no  else if((x>=w/2+50&&y>=75&&x<=w/2+75&&y<=95&&lmb==true)||keyDown(SDLK_n))  {  drawRect(w/2,0,w/2+80,100,RGB_Black);  print("OK", w/2, 0, RGB_White, 0, RGB_Black, 0);  ansMenuYN=false;  }}bool drawNoPassRect(int &avX, int &avY, double &enemyX, double &enemyY, int x, int y, int x2, int y2, ColorRGB color){//draws actual rect drawRect(x,y,x2,y2,color);//border controlif(avX+avatarWidth>x-avSpeed&&avX<x&&avY<y2&&avY+avatarHeight>y)    {avX=x-avatarWidth;}if(avX<x2+avSpeed&&avX>x&&avY<y2&&avY+avatarHeight>y)   {avX=x2;}if(avY>y-avatarHeight-avSpeed&&avY<y2&&avX+avatarWidth>x&&avX<x2){avY=y-avatarHeight-avSpeed;}if(avY<y2+avSpeed&&avY>y&&avX+avatarWidth>x&&avX<x2)  {avY=y2+avSpeed;}//enemy border control//enemy dimension initlalizationif(activeEnemy=="rabbit"){enemyWidth=rabbitWidth;enemyHeight=rabbitHeight;}//if(enemyX+enemyWidth>x-avSpeed&&enemyX<x&&enemyY<y2&&enemyY+enemyHeight>y)    {enemyX=x-enemyWidth-1;}if(enemyX<x2+avSpeed&&enemyX>x&&enemyY<y2&&enemyY+enemyHeight>y)   {enemyX=x2+1;}if(enemyY>y-enemyHeight-avSpeed&&enemyY<y2&&enemyX+enemyWidth>x&&enemyX<x2){enemyY=y-enemyHeight-avSpeed-1;}if(enemyY<y2+avSpeed&&enemyY>y&&enemyX+enemyWidth>x&&enemyX<x2)  {enemyY=y2+avSpeed+1;}//is avatar close?if((avX==x-avatarWidth||avX==x2||avY==y-avatarHeight-avSpeed||avY==y2+avSpeed)){if(avX+avatarWidth>x-avSpeed&&avX<x2+avSpeed&&avY>y-avatarHeight-avSpeed-1&&avY<y2+avSpeed+1){return true;}}else{return false;}}bool drawNoPassRect(int &avX, int &avY, double &enemyX, double &enemyY, int x, int y, int x2, int y2){//invisible rect//border controlif(avX+avatarWidth>x-avSpeed&&avX<x&&avY<y2&&avY+avatarHeight>y){avX=x-avatarWidth;}if(avX<x2+avSpeed&&avX>x&&avY<y2&&avY+avatarHeight>y){avX=x2;}if(avY>y-avatarHeight-avSpeed&&avY<y2&&avX+avatarWidth>x&&avX<x2){avY=y-avatarHeight-avSpeed;}if(avY<y2+avSpeed&&avY>y&&avX+avatarWidth>x&&avX<x2){avY=y2+avSpeed;}//enemy border control//enemy dimension initlalizationif(activeEnemy=="rabbit"){enemyWidth=rabbitWidth;enemyHeight=rabbitHeight;}//if(enemyX+enemyWidth>x-avSpeed&&enemyX<x&&enemyY<y2&&enemyY+enemyHeight>y)    {enemyX=x-enemyWidth-1;}if(enemyX<x2+avSpeed&&enemyX>x&&enemyY<y2&&enemyY+enemyHeight>y)   {enemyX=x2+1;}if(enemyY>y-enemyHeight-avSpeed&&enemyY<y2&&enemyX+enemyWidth>x&&enemyX<x2){enemyY=y-enemyHeight-avSpeed-1;}if(enemyY<y2+avSpeed&&enemyY>y&&enemyX+enemyWidth>x&&enemyX<x2)  {enemyY=y2+avSpeed+1;}//is avatar close?if((avX==x-avatarWidth||avX==x2||avY==y-avatarHeight-avSpeed||avY==y2+avSpeed)){if(avX+avatarWidth>x-avSpeed&&avX<x2+avSpeed&&avY>y-avatarHeight-avSpeed&&avY<y2+avSpeed){return true;}}else{return false;}}    void weaponSelector(){  //read mouse  int x, y;   bool lmb, rmb;  getMouseState(x, y,lmb,rmb);  //test which weapon selected  if(showCursor==true){ShowCursor(true);}  else{ShowCursor(false);}    if(keyDown(SDLK_1)&&knifeLvlOne==true)  {weapon=1;  }  if(keyDown(SDLK_2)&&shortSwordLvlTwo==true)  {weapon=2;  }if(weapon==1){  drawRect(43,0,60,18,RGB_Yellow);  showCursor=false;  drawKnife(x,y);  }  else if(weapon==2)  {  drawRect(58,0,75,18,RGB_Yellow);  showCursor=false;  drawShortSword(x,y);  }  }void drawKey(int x, int y){   drawRect(x,y,x+15,y+2,RGB_Yellow);   drawRect(x,y,x+2,y+5,RGB_Yellow);   drawRect(x+13,y,x+15,y+5,RGB_Yellow);   drawRect(x,y+5,x+15,y+7,RGB_Yellow);   drawRect(x+7,y+7,x+8,y+15,RGB_Yellow);   drawRect(x+8,y+10,x+12,y+11,RGB_Yellow);   drawRect(x+8,y+13,x+12,y+14,RGB_Yellow);}void drawKnife(int x, int y){drawRect(x-1,y-1,x+3,y+6,RGB_Grey);drawRect(x,y,x+2,y+5,RGB_Black);drawLine(x+1, y-1, x+1, y-7, RGB_Grey);}void drawShortSword(int x, int y){drawRect(x-1,y-1,x+3,y+6,RGB_Grey);drawRect(x,y,x+2,y+5,RGB_Black);drawRect(x, y-9, x+2, y, RGB_Grey);}bool drawHouse(int &avX,int &avY,int x,int y){drawNoPassRect(avX,avY,enemyX,enemyY,x,y,x+400,y+125,RGB_Maroon);drawNoPassRect(avX,avY,enemyX,enemyY,x+25,y+125,x+375,y+225,RGB_Red);//drawRect(x+25,y+125,x+375,y+225,RGB_Red);drawRect(x+99,y+149,x+201,y+225,RGB_Black);drawRect(x+100,y+150,x+200,y+225,RGB_Brown);drawRect(x+148,y+150,x+152,y+225,RGB_Black);//is avatar close to door?if(avX+avatarWidth>x+99&&avX<x+201&&avY>y+225&&avY<y+250){return true;}else{return false;}} int getAvatarX(int x, int y){   readKeys(); int avatarX=x;  if(keyDown(SDLK_RIGHT)){ avatarX+=avSpeed; ansMenuYN=true; } else if(keyDown(SDLK_LEFT)){    avatarX-=avSpeed;ansMenuYN=true; }  return avatarX;} int getAvatarY(int x, int y){   readKeys(); int avatarY=y;  if(keyDown(SDLK_UP)){  for(int i=0;i<avSpeed;i++){avatarY--;} ansMenuYN=true; } else if(keyDown(SDLK_DOWN)){    avatarY+=avSpeed;    ansMenuYN=true; }  return avatarY;}void drawAvatar(int posX, int posY){  drawNoPassRect(avX,avY,enemyX,enemyY,posX,posY,posX+avatarWidth,posY+avatarHeight,RGB_Blue);  }void ScreenOne(){grass();}void ScreenTwo(){stone();}////LEVEL SCREENS!/////////////////////////////////////////////////////////////////////////////////////void screenTester(int &screen, int &avX, int &avY){if(screen==-2){//floordrawRect(100,100,w-100,h-100,RGB_Brown);//floor border controlif(avX<100){avX=100;}if(avX>w-100-avatarWidth){avX=w-100-avatarWidth;}if(avY>h-100-avatarHeight){avY=h-100-avatarHeight;}if(avY<100){avY=100;}//test for knife on floorif(shortSwordLvlTwo==false){//place short sword   drawShortSword(200,200);//check if near short swordif(avX>180&&avX<220&&avY>180&&avY<220){nearShortSwordLvlTwo=true;}else{nearShortSwordLvlTwo=false;}  //knife menu if(nearShortSwordLvlTwo==true)  {  menuMakerObjects(shortSwordLvlTwo,"Pick up short sword?","You got the short sword!","drawShortSword",weapon); }  }  //draw exit    drawRect(300,h-115,375,h-100,RGB_Black); //check if near exit if(avX+avatarWidth>300&&avX<375&&avY+avatarHeight>h-116&&avY<h-99){nearHouseExit=true;}else{nearHouseExit=false;}    //exit menu   if(nearHouseExit==true)    {    menuMakerDoors("leave the house?",screen,2,avX,avY);    }}//inside house level oneif(screen==-1){//floordrawRect(100,100,w-100,h-100,RGB_Brown);//floor border controlif(avX<100){avX=100;}if(avX>w-100-avatarWidth){avX=w-100-avatarWidth;}if(avY>h-100-avatarHeight){avY=h-100-avatarHeight;}if(avY<100){avY=100;}//test for knife on floorif(knifeLvlOne==false){//place knife   drawKnife(200,200);//check if near knifeif(avX>180&&avX<220&&avY>180&&avY<220){nearKnifeLvlOne=true;}else{nearKnifeLvlOne=false;}  //knife menu if(nearKnifeLvlOne==true)  {  menuMakerObjects(knifeLvlOne,"Pick up knife?","You got the knife!","drawKnife",weapon); }  }//draw exit    drawRect(300,h-115,375,h-100,RGB_Black); //check if near exit if(avX+avatarWidth>300&&avX<375&&avY+avatarHeight>h-116&&avY<h-99){nearHouseExit=true;}else{nearHouseExit=false;}    //exit menu   if(nearHouseExit==true)    {    menuMakerDoors("leave the house?",screen,1,avX,avY);    }  }if(screen==1){grass();//testdrawNoPassRect(avX,avY,enemyX,enemyY,700,300,750,350,RGB_Red);////left walldrawNoPassRect(avX,avY,enemyX,enemyY,0,0,5,h-1,RGB_Red);for(int i=0;i<=h;i+=10){   drawRect(0,i,5,i+2,RGB_Black);   }//top walldrawNoPassRect(avX,avY,enemyX,enemyY,0,0,w-1,5,RGB_Red);for(int i=0;i<=w;i+=10){   drawRect(i,0,i+2,5,RGB_Black);   }//right walldrawNoPassRect(avX,avY,enemyX,enemyY,w-5,0,w-1,h-100,RGB_Red);drawNoPassRect(avX,avY,enemyX,enemyY,w-5,h-50,w-1,h-1,RGB_Red);for(int i=0;i<=h-100;i+=10){   drawRect(w-5,i,w-1,i+2,RGB_Black);   }for(int i=h-50;i<=h-1;i+=10){   drawRect(w-5,i,w-1,i+2,RGB_Black);   }//bottom trees    //leftfor(int i=w/2-65;i>=0;i-=50){   drawDisk(i,h-15,30,RGB_Darkgreen);   } for(int i=w/2-65;i>=0;i-=50){   drawDisk(i,h-15,20,RGB_Olive);   } for(int i=w/2-65;i>=0;i-=50){   drawDisk(i,h-15,10,RGB_Darkgreen);   }   //rightfor(int i=w/2+65;i<=w;i+=50){   drawDisk(i,h-15,30,RGB_Darkgreen);   } for(int i=w/2+65;i<=w;i+=50){   drawDisk(i,h-15,20,RGB_Olive);   } for(int i=w/2+65;i<=w;i+=50){   drawDisk(i,h-15,10,RGB_Darkgreen);   }   //border control   drawNoPassRect(avX,avY,enemyX,enemyY,0,h-40,w/2-45,h);   drawNoPassRect(avX,avY,enemyX,enemyY,w/2+45,h-40,w,h);//draw boulder and check if nearif(drawNoPassRect(avX,avY,enemyX,enemyY,w-95,50,w-50,75,RGB_Gray)==true){nearBoulderLvl[1]=true;}else {nearBoulderLvl[1]=false;} //boulder menu   if(nearBoulderLvl[1]==true)   {  menuMakerObjects(keyLvl[1],"Look under boulder?","You found a key!","numKeys",numKeys);   }//draw house and  //check if near house  if(drawHouse(avX,avY,50,50)==true)  {   nearHouseLvl[1]=true;  }else{nearHouseLvl[1]=false;}    //house menu if(nearHouseLvl[1]==true)  {   menuMakerDoors("Enter the house?",screen,-1,keyLvl[1],"You need the key!",avX,avY);}   }else if(screen==2){stone();//draw house and  //check if near houseif(drawHouse(avX,avY,100,100)==true)  {   nearHouseLvl[1]=true;  }else{nearHouseLvl[1]=false;}    //house menu if(nearHouseLvl[1]==true)  {  menuMakerDoors("Enter the house?",screen,-2,2,"You need the key!",avX,avY);  } createEnemy(1,"rabbit",600,200,EnemyX[1],EnemyY[1],numKeys);  createEnemy(2,"rabbit",100,20,EnemyX[2],EnemyY[2],numKeys);  }else if(screen==6){snow();//if(avX<1){avX=1;}//}//actual level changingif(avX>w){ avX=1; screen++; }else if(avX<0){avX=w; screen--;}else if(avY>h){avY=1;screen+=NumScrWide;}else if(avY<0){avY=h;screen-=NumScrHigh;}//    }[Edited by - BlueBan007 on April 28, 2009 7:08:24 AM]
  It's your project, your homework.  Nobody is going to do it for you, if you require help or don't think you know something well enough then you should ask your teacher.  That being said if you had a very specific question about something then somebody may help, but just posting your pile of code and asking somebody to improve it is a bit much.   ;  ok ok, this is not homework. this is a class project i wrote by myself...i am getting no help from my classmates b/c they dont care, and i have a first year teacher who knows less than me...I need help.This is in no way a do my homework thing.if it was, i definitely wouldnt have mentioned school...but i am stuck...   ;  Firstly, when posting code use source tags. Secondaly very few peope have time to read all that code. Work out one or two bits that are relevant to a specific question you want solved.   ;  Not what you asked for but.. //set keys for game to not found bool keyLvl[500]; //set all enemies to not killed bool enemyDead[500];These variables aren't initialised here.  They may default to false in debug mode, but you can't rely on that.As for the rendering problem, is the render function being called on both rabbits?  Do you know how to use break points?   ;  I know you didn't ask for it so feel free to ignore it, but you could clean up the code somewhat too make it a little more readable for everyone. [smile]void drawEnemy(std::string type,int &avX,int &avY,double &enemyX,double &enemyY)Why are you passing all the 'numbers' by reference and the string by value?if(checkForAttack(enemyNumber,type,enemyHealth,enemyX,enemyY)==true)It's a matter of style of course, but most people would omit the ==true part. More or less the same can be said for the occurrences of ==false.if(enemyDead[enemyNumber]==false&&enemyX>avX-rabbitWidth*2&&enemyX<avX+avatarWidth+rabbitWidth&&enemyY>avY-rabbitHeight*2&&enemyY<avY+avatarHeight+rabbitHeight)Perhaps some extra white space is in order. Or you can abstract it away in a new function/method.if(enemyHealth<rabbitHealth){  return true;  } else{return false;}}You could shorten this to return (enemyHealth < rabbitHealth).And for this particular issue: can you bring down the amount of code to isolate the problem area? This will make it easier for everybody to read, and it will probably give you a better understanding of the problem as well.   ;  I'm not clear on what this huge problem you're experiencing is. But one thing I've noticed is you seem to be doing too many things in your functions.  In a function like createEnemy you really only want to be getting the enemy set to enter gameplay.  Whatever function is calling createEnemy should probably be responsible for drawing, attacking, and moving.  If the problem is AI for enemy movement then consider making enemy movement seperate from checkForAttack.Consider taking a step back and replanning your program using pseudocode. Basicly, you should be able to plan the various steps of your program without spending considerable time writting any real code.  Or if you prefer, plan it out with pen and paper.  A general outline might help considerably with orginisation, planning, and your understanding of the program you're writting.   ;  ok i got it, thanks   