Autor Beitrag
manta656
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 18



BeitragVerfasst: Sa 14.03.09 14:53 
Moin , ich wollte für ein Spiel , einen Rechner machen , der Rechnet wie viel EP man noch braucht für lvl 2 usw.
ich habe es mir so vorgestellt :
eine combobox , wo man das LvL raussuchen kan , das man will. ein edit feld , um seine ep anzugeben , die man hat. ein knopf zum ausrechnen und dan ein edit feld , wo das resultat kommt.
So soll gerechnet werden :
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
Level 1: 
Level 2: 10'000 EP
Level 3: 20'000 EP
Level 4: 40'000 EP
Level 5: 80'000 EP
Level 6: 160'000 EP
Level 7: 320'000 EP
Level 8: 640'000 EP
Level 9: 1'280'000 EP
Level 10: 2'560'000 EP
Level 11: 5'120'000 EP
Level 12: 10'240'000 EP
Level 13: 20'480'000 EP
Level 14: 40'960'000 EP
Level 15: 81'920'000 EP
Level 16: 163'840'000 EP
Level 17: 327'680'000 EP


das sind die EP zahlen , die man braucht fürs nächste level.

Wie soll ich das nun programmieren ?





eigentlich habe ich es mir so vorgestellt , wie es aussieht ganz Grob ohne verschönerungen :
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:
object Form1: TForm1
  Left = 192
  Top = 112
  Width = 414
  Height = 239
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 208
    Top = 64
    Width = 3
    Height = 13
    Caption = '-'
  end
  object Label2: TLabel
    Left = 72
    Top = 160
    Width = 81
    Height = 13
    Caption = 'Die fehlen noch :'
  end
  object Label3: TLabel
    Left = 288
    Top = 160
    Width = 14
    Height = 13
    Caption = 'EP'
  end
  object Edit1: TEdit
    Left = 232
    Top = 64
    Width = 121
    Height = 21
    TabOrder = 0
    Text = 'Deine Ep Zahl'
  end
  object Button1: TButton
    Left = 176
    Top = 112
    Width = 75
    Height = 25
    Caption = 'Rechnen'
    TabOrder = 1
    OnClick = Button1Click
  end
  object ComboBox1: TComboBox
    Left = 56
    Top = 64
    Width = 145
    Height = 21
    ItemHeight = 13
    TabOrder = 2
    Text = 'LvL Auswählen'
    OnChange = ComboBox1Change
    Items.Strings = (
      'Level 1'
      'Level 2'
      'Level 3'
      'Level 4'
      'Level 5'
      'Level 6'
      'Level 7'
      'Level 8'
      'Level 9'
      'Level 10'
      'Level 11'
      'Level 12'
      'Level 13'
      'Level 14'
      'Level 15'
      'Level 16')
  end
  object Edit2: TEdit
    Left = 160
    Top = 152
    Width = 121
    Height = 21
    TabOrder = 3
  end
  object TwilightColorMap1: TTwilightColorMap
    HighlightColor = clBlack
    BtnFrameColor = clBlack
    DisabledColor = cl3DDkShadow
  end
end
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19339
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 14.03.09 15:00 
Du meinst du gibst das Startlevel ein und es sollen die nötigen Erfahrungspunkte bis zum maximalen Level angegeben werden? Du kannst dir ja ein Array machen, in dem die nötigen Erfahrungspunkte stehen. Und dann gehst du alle noch folgenden Level durch.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
const
  MyArray = array[0..3of Integer = (0100002000040000);

NeededEP := 0;
for i := ComboBox1.ItemIndex to High(MyArray) do
  Inc(NeededEP, MyArray[i]);
Oder meinst du nur bis zum nächsten Level? Dafür braucht man ja eigentlich kein Programm, das rechnet man ja im Kopf viel schneller.

Wie auch immer, so in der Art kannst du all das machen.
freak4fun
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 604
Erhaltene Danke: 4

Win 7 Pro
VS 2013 Express, Delphi, C#, PHP, Java
BeitragVerfasst: Sa 14.03.09 15:06 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
procedure TForm1.Button1Click(Sender: TObject);
begin
  with ComboBox1 do
    begin
      AddItem('Level1', TObject(10000)); // Integer als TObject casten
      AddItem('Level2', TObject(20000));
      AddItem('Level3', TObject(40000));
      AddItem('Level4', TObject(60000));
      AddItem('Level5', TObject(1200000));
    end;
end;

procedure TForm1.ComboBox1Click(Sender: TObject);
begin
  ShowMessage(IntToStr(Integer(ComboBox1.Items.Objects[ComboBox1.ItemIndex]))); // zurückcasten
end;

_________________
"Ich werde auf GAR KEINEN Fall…!" - "Keks?" - "Okay, ich tu's."
i++; // zaehler i um 1 erhoehen
manta656 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 18



BeitragVerfasst: Sa 14.03.09 15:19 
danke danke hat mir weitergeholfen , ist aber nicht genau das was ich will ;) jedoch werde ich es jetzt versuchen , da ich in euren codes nützliche sachen gefunden hab :D wens klappt sag ich euch bescheid , wen nicht dan auch xD und ja es geht gut im Kopf , aber wen du
63'840'000 EP brauchst und du hast 59'357'952 Ep dan gehts doch schneller mit dem Rechner^^ ist aber auch um Erfahrung mit Delphi zu sammeln.

Und ja ich meine er soll die Anzahl Rechnen , bis zum nächsten level also wie viel man noch braucht


Zuletzt bearbeitet von manta656 am Sa 14.03.09 15:26, insgesamt 1-mal bearbeitet
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19339
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 14.03.09 15:22 
user profile iconmanta656 hat folgendes geschrieben Zum zitierten Posting springen:
und ja es geht gut im Kopf , aber wen du
63'840'000 EP brauchst und du hast 59'357'952 Ep dan gehts doch schneller mit dem Rechner^^
Bei mir garantiert nicht. ;-)

user profile iconmanta656 hat folgendes geschrieben Zum zitierten Posting springen:
ist aber auch um Erfahrung mit Delphi zu sammeln.
Das ist natürlich ein Argument. ;-)

Wenn es nur um das aktuelle Level geht, dann kannst du das Array durchgehen bis der Wert größer ist um zu schauen in welchem Level man sich gerade befindet bei den angegebenen EP. Und dann kannst du von diesem Wert die angegebenen EP abziehen.
manta656 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 18



BeitragVerfasst: Sa 14.03.09 15:30 
also das Level sieht man auch im spiel da steht dan
EP: XXXXXXXX
LvL : XX
ich möchte die Differenz wissen , wie viel EP man braucht fürs nächste level ;)
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19339
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 14.03.09 15:49 
Wenn du das aktuelle Level nicht einmal an den Erfahrungspunkten ablesen willst, dann ist das ja nur eine Zeile, weil du den Index der ComboBox direkt im Array benutzen kannst.
Alternativ kannst du es natürlich auch wie oben von user profile iconfreak4fun gezeigt machen, aber ich glaube das ist nicht ganz so schön.