NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io


package oyun;

import java.util.Scanner;

public class Game
{
public static int GAME_SIZE = 8;
public static Entity[][] map = new Entity[GAME_SIZE][GAME_SIZE];

public static int monsterCount = GAME_SIZE - 1;
public static Player player = new Player();
public static int PX =0, PY = 0;
public static Scanner oku = new Scanner(System.in);

public static void initGame()
{
// Haritadaki Tüm Alanları, Boş Entity Instance'lariyla
// Doldur
for (int i = 0; i< GAME_SIZE; i++)
for (int j = 0; j< GAME_SIZE; j++)
map[i][j] = new Entity();

// Oyuncuyu 0x0'a Yerleştir
map[0][0] = player;

// 1,2,3,4,5,6,7 Satırlara, X'ler Random Olacak Şekilde
// Canavarlar Yerleştir
for (int i = 1; i<GAME_SIZE; i++)
{
int r = (int) (Math.random() * 2);
int rX = (int)(Math.random() * GAME_SIZE);
// Eğer r 0 İse, rX'e Goblin, r 1 İse, rX'e Mamoot
// Yerleştir,
Entity monster = (r == 0) ? new Goblin() : new Mamoot();
/*
Entity monster = null;
if (r == 0) monster = new Goblin();
else monster = new Mamoot();
*/
map[i][rX] = monster;
}
}

public static void printMap()
{
System.out.println("nn");
for (int i = 0; i < GAME_SIZE; i++)
{
for (int j = 0; j < GAME_SIZE; j++)
{
System.out.print(map[i][j]);
}
System.out.println("");
}
System.out.println("nn");
System.out.println("Can : "+player.hp + "LVL : "+ player.level +"Gold : "+player.goldCnt);
}


public static void main(String[] args)
{
initGame();

while (monsterCount > 0 && player.isAlive())
{
printMap();
System.out.print("Yon : w,s,a,d : ");
char yon = oku.next().toLowerCase().charAt(0);
int tmpX = PX;
int tmpY = PY;

switch(yon)
{
case 'w' : tmpY--; break;
case 's' : tmpY++; break;
case 'a' : tmpX--; break;
case 'd' : tmpX++; break;
}

// Harita Dışına Çıkılıyorsa, Hareket Etme
if (tmpX < 0 || tmpY < 0 || tmpX >= GAME_SIZE || tmpY >= GAME_SIZE)
{
continue;
}

// Eğer Hareketin Sonucunda, Oyuncu Haritanın İçinde
// Kalıyorsa, Hareket Ettiği Yerde Canavar Var Mı
// Diye Kontrol Et
Entity nextMove = map[tmpY][tmpX];
// Bu Alan Boş, Oyuncu Hareket Edebilir
if (nextMove.avatar.equals(" "))
{
map[PY][PX] = new Entity();
map[tmpY][tmpX] = player;
PX = tmpX;
PY = tmpY;
}
else
{
System.out.print("Gitmek İstediğiniz Noktada Bir Canavar Var. Emin misiniz ? (1-E, 2-H)");
int sec = oku.nextInt();
if (sec == 2)
continue;

if (sec == 1)
{
System.out.println("SAVAŞ BAŞLIYOR");
Entity canavar = map[tmpY][tmpX];
System.out.println(
"Bir "+canavar.getClass().getName()+" İle Karşılaştın");

// TODO SAVASMA
/*
Savaş Mekanizması :
Herzaman İlk Oyuncu Vurur
Rand(0.5 DMG - DMG)
Sonra Canavar
Bu Sira İle Vurma İşlemi,
2 Taraftan Birinin HP Değer <= 0 Olana
Kadar Devam Edecek.
Eğer Oyuncunun HP'si 0 Olursa,
Döngü Kırılacak

*/


if (canavar instanceof Goblin)
{
Goblin g = (Goblin) canavar;
while (g.isAlive() && player.isAlive())
{
int pVurus = 0 , cVurus = 0;
pVurus=(int) (Math.random()*player.dmg) ;
g.hp -= pVurus;
System.out.println("Vurus Gucu : "+pVurus +"Canavarin Kalan Cani : "+g.hp);
if (g.hp<0) break;
cVurus=(int) (Math.random()*(g.dmg)) ;
player.hp -= cVurus;
System.out.println("Alinan Darbe : "+cVurus +"Kalan Can : "+ player.hp) ;
if (player.hp<0) break;
}
player.goldCnt += g.goldDrop;
}

if (canavar instanceof Mamoot){
Mamoot m = (Mamoot) canavar;
while (m.isAlive() && player.isAlive())
{
int pVurus = 0 , cVurus = 0;
pVurus=(int) (Math.random()*player.dmg) ;
m.hp -= pVurus;
System.out.println("Vurus Gucu : "+pVurus +"Canavarin Kalan Cani : "+(m.hp));
if (m.hp<0) break;
cVurus=(int) (Math.random()*(m.dmg)) ;
player.hp -= cVurus;
System.out.println("Alinan Darbe : "+cVurus +"Kalan Can : "+ player.hp) ;
if (player.hp<0) break;
}
player.goldCnt += m.goldDrop;
}

player.killCnt += 1;

map[PY][PX] = new Entity();
map[tmpY][tmpX] = player;
PY = tmpY;
PX = tmpX;

monsterCount--;
if (monsterCount % 2 == 0) player.lvlUp();
}
}
}

// Dongu Bitince, Eğer Canavar Sayısı 0 Ise
// Oyun Kazanıldı
// Ama Hala Canavar Varsa, Karakter Olmus Demektir
if (monsterCount == 0)
{
System.out.println("Tebrikler !");
}
else
{
System.out.println("Öldünüz, Oyun Bitti");
}

}

// Kullanıcı Her GAMESIZE /3 - 1 Canavar Oldurdugune
// Level Atlayacak.
// Her Level Atladığında
// Canına +10, DMG'a +2 Eklenecek Ve CAnı Fullenecek
// Harita Basildiktan Sonra, Kullanıcının Statlarını
// Haritanın Altına Bastıracaksınız
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.