private void PremistiJidlo() { int x = random.Next(0, canvas.Width / 20); int y = random.Next(0, canvas.Height / 20); if (had.JsiNaTetoPozici(x, y)) { PremistiJidlo(); } else { if (count % 5 == 0 && count != 0) { jidlo = new BonusoveJidlo(x, y); progressBar1.Value = 100; bonusovyTimer.Start(); count = -1; } else { bonusovyTimer.Stop(); progressBar1.Visible = false; jidlo = new Jidlo(x, y); } } }
public void PosunSe(Jidlo jidlo) { hlava.PohniSe(); foreach (CastHada c in castiTela) { c.PohniSe(); } for (int i = castiTela.Count - 1; i > 0; i--) { castiTela[i].ZmenSmer(castiTela[i - 1]); } castiTela[0].ZmenSmer(hlava); if (novaCast != null) { novaCast.ZmenSmer(castiTela.Last()); castiTela.Add(novaCast); novaCast = null; } if (hlava.Pozice == jidlo.Pozice) { Jez(); } foreach (CastHada cast in castiTela) { if (cast.Pozice == hlava.Pozice) { Umri(); } } if (hlava.Pozice.X < 0 || hlava.Pozice.X > sirkaPole - 1) { Umri(); } if (hlava.Pozice.Y < 0 || hlava.Pozice.Y > vyskaPole - 1) { Umri(); } }