Autor Beitrag
Andreas95
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 36



BeitragVerfasst: So 09.01.11 18:43 
Also hier habe ich ein kleines Spiel gemacht wo man einfach mit den links und rechts Tasten eine Figur bewegt, die immer weiter an Platformen hoch springt. (hab die idee natürlich von Doodle Jump)
erwartet nicht viel von der Grafik, denn alles wurde mit Paint Gemalt.
Die platformen sind shapes.

Hier mein code:
(beachtet die unordnung fürs erste einfach nicht, denn alles wurde mit nur meiner linken Hand programmiert weil meine Rechte kaputt ist, also hab ich weniger darauf geachtet.).
Kritik, ideen, verbesserungsvorschläge höre ich gern ;)

-------------->EDIT[11.01.2011]<------------------
Danke für die vorschläge, ich hab jetzt entschieden das programm weiter zu führen (und wenn ich wieder 2 Hände habe auch mal aufzuräumen)
In der Version:
Graphik Verbessert (Ganz wenig),
Sprung Fliesender gemacht (bewerten bitte),
Sprung Bugs behoben (über Bildschirm hinaus gehen und Unerreichbare Platforme),
ein "gegner" geaddet (anfangsphase, immernoch total verbuggt :/),
Punkte Gebung gerichtet.
Ich freue mich weiterhin für Feedback :) (ich weiss es ist nichts besonderes, aber spass macht es dennoch schon ein wenig) :D Den Gegner mit ein mausclick "töten".
Acsho, und ich war zu faul um alles in eine zip datei zu fügen statt alles an der form zu kleben, aber mache ich bald)

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405:
406:
407:
408:
409:
410:
411:
412:
413:
414:
415:
416:
417:
418:
419:
420:
421:
422:
423:
424:
425:
426:
427:
428:
429:
430:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    Image1: TImage;
    Timer1: TTimer;
    Timer2: TTimer;
    Timer3: TTimer;
    Panel1: TPanel;
    Label1: TLabel;
    StaticText1: TStaticText;
    Timer4: TTimer;
    Label2: TLabel;
    Panel2: TPanel;
    Image3: TImage;
    Image2: TImage;
    Label3: TLabel;
    StaticText2: TStaticText;
    Label4: TLabel;
    Image4: TImage;
    P1: TImage;
    P2: TImage;
    P3: TImage;
    P4: TImage;
    P5: TImage;
    P6: TImage;
    P7: TImage;
    P8: TImage;
    Image5: TImage;
    Timer5: TTimer;
    Image6: TImage;
    Timer6: TTimer;
    Image7: TImage;
    Image8: TImage;
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Timer2Timer(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormKeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure adjust;
    procedure lose;
    procedure Timer3Timer(Sender: TObject);
    procedure Timer4Timer(Sender: TObject);
    procedure Image2Click(Sender: TObject);
    procedure Image3Click(Sender: TObject);
    procedure StaticText2Click(Sender: TObject);
    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure FormClick(Sender: TObject);
    procedure Image1Click(Sender: TObject);
    procedure Timer5Timer(Sender: TObject);
    procedure Image6MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Timer6Timer(Sender: TObject);
    procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;
  const name = 'Highscores';
var
  Form1: TForm1;
  up,l,
  move,
  adj,restart,
  pig: boolean;
  t,a,b,
  adjusttime,
  ra,re,
  score,scor,
  cord,space,
  time,
  pic: integer;
  shapes: array[1..8of timage;
  sh: array[1..3of boolean;
  HS: tstringlist;

implementation

{$R *.dfm}

procedure tform1.lose;
begin
 timer1.Enabled := false;
 timer2.Enabled := false;
 timer3.enabled := true;
 panel1.Visible := true;
 label2.Caption := 'Du hast '+statictext1.Caption+' Punkte geschafft!';
 //try hs.loadfromFile(Name);
 //except
 // hs.Add('lol')
 //end;
end;
procedure tform1.adjust;
var i: integer;
begin

  inc(adjusttime);
 //if adjusttime <70 then
  //begin
   // for i := 1 to 8 do shapes[i].top := shapes[i].Top + 1; //image1.Top := image1.Top +1;
    //if adjusttime = 50 then
      //begin
        //adjusttime := 0;


    if P1.Top > form1.Height then
    begin
      P1.Top := ra;
      re := 1;
      P1.Left := random(space);
      if p1.Left > clientwidth then p1.Left := p1.Left - clientwidth;
      if p1.Left < 0 then p1.Left := clientwidth + p1.Left;
    end;

    if P2.Top > form1.Height then
    begin
      P2.Top := ra;
       re := 2;
       P2.Left := random(space);
      if p2.Left > clientwidth then p2.Left := p2.Left - clientwidth;
      if p2.Left < 0 then p2.Left := clientwidth + p2.Left;
    end;

    if P3.Top > form1.Height then
    begin
      P3.Top := ra;
       re := 3;
       P3.Left := random(space);
      if p3.Left > clientwidth then p3.Left := p3.Left - clientwidth;
      if p3.Left < 0 then p3.Left := clientwidth + p3.Left;
    end;

    if P4.Top > form1.Height then
    begin
      P4.Top := ra;
       re := 4;
      P4.Left := random(space);
      if p4.Left > clientwidth then p4.Left := p4.Left - clientwidth;
      if p4.Left < 0 then p4.Left := clientwidth + p4.Left;
    end;

    if p5.Top > form1.Height then
    begin
      p5.Top := ra;
       re := 5;
              p5.Left := random(space);
      if p5.Left > clientwidth then p5.Left := p5.Left - clientwidth;
      if p5.Left < 0 then p5.Left := clientwidth + p5.Left;
    end;

    if p6.Top > form1.Height then
    begin
      p6.Top := ra;
       re := 6;
              p6.Left := random(space);
      if p6.Left > clientwidth then p6.Left := p6.Left - clientwidth;
      if p6.Left < 0 then p6.Left := clientwidth + p6.Left;
    end;

    if p7.Top > form1.Height then
    begin
      p7.Top := ra;
       re := 7;
              p7.Left := random(space);
      if p7.Left > clientwidth then p7.Left := p7.Left - clientwidth;
      if p7.Left < 0 then p7.Left := clientwidth + p7.Left;
    end;

    if p8.Top > form1.Height then
    begin
      p8.Top := ra;
       re := 8;
              p8.Left := random(space);
      if p8.Left > clientwidth then p8.Left := p8.Left - clientwidth;
      if p8.Left < 0 then p8.Left := clientwidth + p8.Left;
    end;

  ra := shapes[re].Top -100;

end;
procedure TForm1.Timer1Timer(Sender: TObject);
var i: integer;
begin
   if image1.Top <= image6.Top + image6.Height then
    if image1.top >= image6.Top then
      if image1.Left <= image6.Left + image6.Width then
        if image1.Left >= image6.Left - image1.Width then
          lose;
      adjust;
  if l then if move then image1.Left :=image1.Left - 4;
  if not l then if move then image1.Left :=image1.Left + 4;
  inc(t);
  if t = 55 then begin up := false;  t := 0; timer2.Enabled := true; timer1.Enabled := false; b := 0;  end;
  begin
     inc(b);
     if b > 27 then begin if image1.Top < 168 then begin for i := 1 to 8 do shapes[i].Top := shapes[i].Top +1; image1.Top := image1.top + 1; image6.Top := image6.Top + 1end; image1.Top := image1.Top -1end;
     if b >20 then if b < 28 then begin if image1.Top < 168 then begin for i := 1 to 8 do shapes[i].Top := shapes[i].Top + 2; image1.Top := image1.top + 2; image6.Top := image6.Top + 2end; image1.Top := image1.Top -2;                                                   end;
     if b >16 then if b < 21 then begin if image1.Top < 168 then begin for i := 1 to 8 do shapes[i].Top := shapes[i].Top + 3; image1.Top := image1.top + 3;image6.Top := image6.Top + 3end; image1.Top := image1.Top - 3;     end;
     if b >9 then if b < 17 then begin if image1.Top < 168 then begin for i := 1 to 8 do shapes[i].Top := shapes[i].Top + 4; image1.Top := image1.top + 4;image6.Top := image6.Top + 4end; image1.Top := image1.Top - 4;         end;
     if b <10 then begin if image1.Top < 168 then begin for i := 1 to 8 do shapes[i].Top := shapes[i].Top + 5; image1.Top := image1.top + 5;image6.Top := image6.Top + 5end; image1.Top := image1.Top - 5;                                                                  end;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
var i: integer;
begin
  panel2.Width := 625;
  panel2.Height := 361;
  randomize;
  doublebuffered := true;
  shapes[1] := P1;
  shapes[2] := P2;
  shapes[3] := P3;
  shapes[4] := P4;
  shapes[5] := p5;
  shapes[6] := p6;
  shapes[7] := p7;
  shapes[8] := p8;

  re := 8;

  p7.Top := p6.Top - 100;
  p8.Top := p7.Top - 100;

  space := 79*8;
 // hs := tstringlist.Create;
 for i := 1 to 8 do shapes[i].Picture := p1.Picture;
end;

procedure TForm1.Timer2Timer(Sender: TObject);
var i: integer;
begin
    if image1.Left + (image1.Width div 2)+30 < 0 then image1.left := form1.Width - image1.Width;
    if image1.Left + (image1.Width div 2)-30 > form1.Width then image1.Left := 0;
     // adjust;
     ;

  if l then if move then image1.Left :=image1.Left - 3;
  if not l then if move then image1.Left :=image1.Left + 3;
  if up = false then
  begin
     inc(a);
     if a < 10 then image1.Top := image1.Top + 1;
     if a > 9 then if a < 17 then image1.Top := image1.Top + 2;
     if a > 16 then if a < 21 then image1.Top := image1.Top + 3;
     if a >20 then if a < 30  then image1.Top := image1.Top + 4;
     if a > 29 then image1.Top := image1.Top + 5;
  end;

   if image1.Top + image1.Height > form1.Height then lose;
  if up = false then for i := 1 to 8 do
    if image1.Top + image1.height >= shapes[i].top then
      if image1.Top+image1.Height <= shapes[i].top+shapes[i].Height then
        if image1.Left >= shapes[i].Left - image1.width then
          if image1.Left + image1.Width <= shapes[i].Left + shapes[i].Width + image1.width then
          begin
             timer2.enabled := false;
             timer1.Enabled := true;
             up := true;
             a := 0;
             adj := true;
            if image1.Top < 200 then timer4.Enabled := true;
          end;


end;

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if key = vk_left then
  begin
    l := true;
    move := true;
  end;

  if key = vk_right then
  begin
    l := false;
    move := true;
  end;
end;

procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
   if key = vk_left then
  begin
    move := false;
  end;

  if key = vk_right then
  begin
    move := false;
  end;
end;

procedure TForm1.Timer3Timer(Sender: TObject);
begin
 if panel1.Height < 161 then panel1.Height := panel1.Height +5;
 if panel1.Width < 425 then panel1.Width := panel1.Width +8;
 image6.Left := -200;
end;

procedure TForm1.Timer4Timer(Sender: TObject);
begin
  inc(score,10);
  inc(scor,10);
  statictext1.Caption := inttostr(score);
  if scor >= 367 then begin timer4.Enabled := false; scor := 0end;
  if pig then
   begin
    if scor = 10 then image1.Picture := image5.Picture;
    if scor = 70 then image1.Picture := image2.Picture;
   end;
end;

procedure TForm1.Image2Click(Sender: TObject);
begin
  image1.Picture := image2.Picture;
  image1.Width := image2.Width;
  image1.Height := image2.Height;
  panel2.Visible := false;
  timer2.Enabled := true;
  pig := true;
  
end;

procedure TForm1.Image3Click(Sender: TObject);
begin
  image1.Picture := image3.Picture;
  image1.Width := image3.Width;
  image1.Height := image3.Height;
  panel2.Visible := false;
  timer2.Enabled := true;

  end;

procedure TForm1.StaticText2Click(Sender: TObject);
begin
  
  Restart :=true;
  panel1.Visible := false;
  form1.Cursor := crnone;
  score := 0;
end;

procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  if restart then
  begin
    image1.Top := y;
    image1.Left := x;
  end;
end;

procedure TForm1.FormClick(Sender: TObject);
begin
  restart := false;
  form1.Cursor := crcross;
  if restart = false then
  begin
    timer2.Enabled := true;
    pig := true;
  end;
end;

procedure TForm1.Image1Click(Sender: TObject);
begin
  restart := false;

  timer2.Enabled := true;
  form1.Cursor := crcross;
end;

procedure TForm1.Timer5Timer(Sender: TObject);
begin
  inc(time);
  if time = 10 then
  begin
    image6.visible := true;
   
   image6.Top := shapes[re].Top - image6.Height;
   image6.Left := shapes[re].Left;
   timer6.Enabled := true;
   timer5.Enabled := false;
    time := 0;

  end;
end;

procedure TForm1.Image6MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  image6.Visible := false;
  image6.Left :=-200;
  timer5.Enabled:= true;
  timer6.Enabled:= false;
end;

procedure TForm1.Timer6Timer(Sender: TObject);
begin
  inc(pic);
  if pic = 1 then image6.Picture := image7.Picture;
  if pic = 2 then
  begin
   image6.Picture := image8.Picture;
   pic := 0;
  end;
end;

procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  timer1.Enabled := true;
end;

end.
Einloggen, um Attachments anzusehen!


Zuletzt bearbeitet von Andreas95 am Di 11.01.11 23:11, insgesamt 2-mal bearbeitet
HenryHux
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 542
Erhaltene Danke: 33

Windows 7 Premium
Delphi XE, Eclipse
BeitragVerfasst: So 09.01.11 19:25 
Sieht doch schon ganz gut aus =)
Aber was ich noch verbessern würde ist, dass man immer eine Fläche bekommen kann.
Oft kann man nur abstürzen.

Lg
Niko S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 566
Erhaltene Danke: 10

Win 7, Ubuntu
Lazarus, Turbo Delphi, Delphu 7 PE
BeitragVerfasst: So 09.01.11 21:23 
Und man sollte nicht jedes mal wenn man hoch springt "höher" kommen. Irgendwann ist der Boden unter einem weg...
Man sollte entweder nur dann höher kommen, wenn man höher springt, oder es sollte gleichmäßig höher gehen. Wie in Ice Tower.
Namenlosnameless
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 259
Erhaltene Danke: 6

Windows XP Home Edition, Windos Vista
C#
BeitragVerfasst: So 09.01.11 23:43 
schaut echt gut aus!

Nur das Springen, wirkt etwas unrealistisch :D
die Figur müsste beim Aufsteigen früher langsamer werden!
momentan schauts so aus als würdestdu ohne geschwindigkeitsverlust, einfach an einer virtuellen linie apprallen lässt!

_________________
1:<<Life sucks!!>> 2:<< Well okay>> 1: <<Just Yours>> 2:<<Ohmph>>