Hello everybody. In my country its 2:12 am so be ready to find some unlogic sentences and misspelled words in my post
Java is my friend for already a year. I guess I`ve got the basic skills for programming at the moment.
But I have no experience in game development.
I began reading this forum and understood that I`m ready to ask you, guys, for help.
For the beginning I searched for open source project games and compiled them, studied them and wrote additional stuff.
Eventually the problem:
I have a little bit changed version of the game from http://cokeandcode.com/index.html?page=tutorials.
The Main idea of my topic:
-
I want to add methods of picking a key (the yellow block) and exiting the level (by standing on the white block)
-
It seems a shame to ask, but I dont know where to place the right code.
-
I have the logic implemented in methods, so check out what I`m going to show you.
-
The methods for picking the key:
• I added and boolean variable hasKey in class Entity.java.
• I added a getter and setter method for this variable
• I added an boolean keyValidation() method
public boolean keyValidation(){
if(hasKey == true)
return true;
else
return false;
}
• I guess that i need to set the key true when the entities location (coordinates) are the same as the keys ???
if(???player???[x][y] == map[13][13])
setKey(true);
and if at this moment I`ll reach an true state of the hasKey variable it would be already a good step for me.
2. Method for opening the door.
public void openDoor(){
if(keyValidation() == true)
System.out.println("GameOver");
}
Really the problem doesn`t sound very hard, especially for u, madskilled java man)
But I stopped at this point and I would be very pleased if somebody looks through the project or code and helps me.
Thank you.
The project source:
https://docs.google.com/open?id=0B8BBSI9JDFc4YXpST2hQOXNpdHc
Sincerely yours, tdchk