The literacy of computer science
- 1. // These double slashesare usedinprogrammingtoleave commentsforotherpeople,because the
//symbolstell the computertoignore everthingafterthe slashesuntil the nextline
publicLevelTester(Stringrace,StringnpcRace,intnpcHp,intcurrentlvl,intpHp,intpSh,StarCrafta)
{
setBackground(Color.black); //thisandthe nextline determinethe size andcolorof the window
setSize(800,600);
keys= newboolean[10]; //thisline istohelpthe computerregisterkeypresses
guy = newPlayer(400,500, 50, 50, 5, race, pHp,pSh, currentlvl); //thissectionisaboutvariables
enemyRace =npcRace; // everyone of these linesisinstantiatingadifferentvariable.
game = a;
thislvl =currentlvl;
pRace = race;
guyHp= pHp;
guySh= pSh;
eHp= npcHp;
if(npcHp== 5)
{
npc = newEnemy(300,50, 101, 124, 5, npcRace,20, thislvl);
}
else if(npcHp==7)
{
npc = newEnemy(300,50, 100, 100, 5, npcRace,40, thislvl);
}
else if(npcHp==10)
{
npc = newEnemy(300,50, 100, 100, 5, npcRace,60, thislvl);
}
list= newEnemyList(npcHp*3, npcHp, npcRace,thislvl);
hp = newHeart();
- 2. sh = newShield();
shots= newBullets();
eShots= newBullets();
bShots= newBullets();
pu = newHashMap<String,PowerUp>(); //a listforpowerups ismade here
pu.put("tacticalNukeStrike",new PowerUp("tacticalNukeStrike")); //powerupsare putinthe list
pu.put("concussiveShell",newPowerUp("concussiveShell"));
pu.put("highImpactPayload",new PowerUp("highImpactPayload"));
pu.put("hardenedShield",newPowerUp("hardenedShield"));
pu.put("psionicStorm",new PowerUp("psionicStorm"));
pu.put("timeWarp",new PowerUp("timeWarp"));
pu.put("groovedSpines",newPowerUp("groovedSpines"));
pu.put("fungalGrowth",newPowerUp("fungalGrowth"));
pu.put("transfusion",new PowerUp("transfusion"));
puQueue =newPowerUpQueue<String>();
pUpCount= 0;
power= newArrayList<Image>();
slow= false;
this.addKeyListener(this); //thisactivatesthe windowsabilitytodetectkeypresses
newThread(this).start();
setVisible(true);
if(race.equals("Terran"))//the restissettingwhichrace the playerhaddesiredandloadsthe
//image forthat particularrace
{
try
{
URL url = getClass().getResource("/Korhal.jpg");
image = ImageIO.read(url);
}