Autor Beitrag
somebody
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 167
Erhaltene Danke: 2



BeitragVerfasst: So 08.07.07 16:47 
Hi Leutz,
ich soll für die Schule ein Snake Programmieren, da ich in Info zwischen 2 Noten stehe, abber egal. Ich weiß gerad aber nicht, wie:

-Der aufzusammelnde Punkt sich nach dem einsammeln zufällig die Position ändert

mfg:somebody
Tilo
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1098
Erhaltene Danke: 13

Win7 geg. WInXP oder sogar Win98
Rad2007
BeitragVerfasst: So 08.07.07 17:26 
Wie wäre es mit random?
somebody Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 167
Erhaltene Danke: 2



BeitragVerfasst: So 08.07.07 18:22 
Das ist mir klar, aber wie ändert der Punkt seine Position, nachdem die Schlange ihn berührt hat? Also, wie macht man eine Kollisionsabfrage?
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: So 08.07.07 18:57 
guckscht du hier -> Hausgemachte pixelgenaue kollisionsabfrage

lg elundril
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: So 08.07.07 19:04 
Einfacher wäre es hier, wenn du die Position des Futters einfach in einem TPoint abspeicherst, da es ja nur ein Futter gibt:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
Futter: TPoint;

// ...

Futter.X := 10;
Futter.Y := 10;

if (Snake.X = Futter.X) AND (Snake.Y = Futter.Y) then
  // ...

Canvas.Pixel ist langsam. So eine if-Anweisung schnell.

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
somebody Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 167
Erhaltene Danke: 2



BeitragVerfasst: So 08.07.07 19:14 
welchen variablen typ hat hier Snake, ich habe mit soetwas noch nie gearbeitet.
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: So 08.07.07 19:16 
In dem Fall ist es hier TPoint, aber da die Snake länger ist, könnte man z.B. ein Array of TPoint nutzen.

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
somebody Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 167
Erhaltene Danke: 2



BeitragVerfasst: So 08.07.07 19:30 
Das geht net, wenn der den berührt passiert nets. Ich hab das jetzt aöls test mit 2 kleinen shapes gemacht.
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: So 08.07.07 19:33 
hier im forum gibt es doch ein snake tutorial oder net ? guck dir das mal an, sonst würde ich dir ja meine snake source geben, aber da steig selbst ich net mehr durch ;)

mfg
somebody Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 167
Erhaltene Danke: 2



BeitragVerfasst: Di 17.07.07 14:51 
Ich guck dann mal da.