Zdravím, chtěl bych se zeptat, jestli tady někdo nemá kód na hru Lodě nebo mi stačí říct, jak bych měl postupovat. Děkuji
Fórum › C / C++
Battleship game

http://mujweb.cz/peter.mlich/hry/lode.htm
V prohlizeci si najdes zobrazeni zdrojoveho kodu. Je to teda javascript. Kliknes na start
Postupovat, no...
- udelas 2 pole (osobne davam prednost jednorozmernym, ted)
- do kazdeho pole rozmistis lode od nejvetsich po nejmensi, pokud se tam vejdou. Cyklus bych omezil treba na 100-1000 pokusu. Pokud se mu to nepodari, tak bych to zkusil cele znovu, tak 5x. A pokud ani pak ne, tak bych nabidl moznost uzivateli upravovat. Rozhodne nema smysl, aby ses pokousel rozmistovat spoustu lodi na maly herni plan do nekonecna :)
- pokud mezi nimi chces mezeru, tak do rozmeru lode zahrnes i 1 policko okolo pri zjistovani, zda je tam misto. V tom pripade doporucuji herni plochu rozsirit o 1 bod na kazde strane a pri umistovani prochazet policka +1 dovnitr, aby ses vyhnul neexistujicim hodnotam
- muzes tam pridat i otaceni lodi.
#2 peter
Něco jednodušší by nebylo ? :D
Zkouším si to udělat sám, ale nevím jak pokračovat
#include<stdio.h>
#include<stdlib.h>
#define MAX 5
int main ()
{
int pocet_lodi, x, y, i, j, i2, strela;
char lode[MAX][MAX];
//Všude nastavíme vodu
for (i=0;i<MAX;i++)
{
for (j=0;j<MAX;j++)
{
lode[i][j]='~';
}
}
//Nastavení lodí
pocet_lodi=3;
lode [2][2]='L';
lode [4][2]='L';
lode [3][3]='L';
//Princip hry
printf("Zadej pozici x:");
scanf ("%d",&x);
printf("Zadej pozici y:");
scanf ("%d",&y);
while (3)
{
if (lode[x][y]=='L')
{
printf ("zasah potopena\n");
system("pause");
}
else
{
printf ("Vedle\n");
system("pause");
}
}
system ("pause");
return 0;
}

Přidej příspěvek
Ano, opravdu chci reagovat → zobrazí formulář pro přidání příspěvku
×Vložení zdrojáku
×Vložení obrázku
×Vložení videa
































Uživatelé prohlížející si toto vlákno
Podobná vlákna
Hra Battleship online — založil Mutagen
Game Maker — založil Samuel Lehotský
3D game engine — založil Jarda
Tkinter Game — založil Hike Mike
Moderátoři diskuze