Autor Beitrag
Cano
Hält's aus hier
Beiträge: 6



BeitragVerfasst: Mo 02.06.08 15:14 
Wir sollen in der Schule einen digitalen Würfel erstellen. Könnte einer uns bitte helfen?
Ist sehr dringend.

Wir haben schon folgendes geschafft:
Unser Formular hat 6 Kreise und einen "würfeln"-Button und wenn man auf "würfeln" drückt sollte sich eigentlich ein Feld anders färben.
Was machen wir falsch?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
var x: integer;
begin
  randomize;
      x:=random(6)+1;
   if x=1 then shape1.Brush.color:=clblack;
   if x=2 then shape2.Brush.color:=clblack;
   if x=3 then shape3.Brush.color:=clblack;
   if x=4 then shape4.Brush.color:=clblack;
   if x=5 then shape5.Brush.color:=clblack;
   if x=6 then shape6.Brush.color:=clblack;
    readln;
 end;


Aber irgendwie passiert nichts.
HILFE!!!!!!!!!!!!! :?

Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt
Moderiert von user profile iconChristian S.: Topic aus VisualCLX (Component Library for Cross Platform) verschoben am Mo 02.06.2008 um 15:18
Moderiert von user profile iconNarses: Titel geändert.


Zuletzt bearbeitet von Cano am Mo 02.06.08 17:04, insgesamt 2-mal bearbeitet
platzwart
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1054
Erhaltene Danke: 78

Win 7, Ubuntu 9.10
Delphi 2007 Pro, C++, Qt
BeitragVerfasst: Mo 02.06.08 15:18 
was genau geht da nicht?

und bitte den titel in was aussagekräftiges ändern...
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mo 02.06.08 15:19 
Hallo,

bitte ändere den Titel des Topics, da er wenig über das eigentlich Thema verrät. Hier der entsprechende Absatz aus den Richtlinien:

1.2 Beiträge:
Bitte formuliere den Betreff Deiner Beiträge so, dass andere Mitglieder anhand dieser bereits das eigentliche Thema festmachen können. Beiträge wie etwa "Eine Anfängerfrage" oder "Weiß jemand, wie das geht?" lassen den Leser im Unklaren darüber, was das Thema der Diskussion ist.[...]


Einfach oben bei Deinem ersten Beitrag auf user defined image oder user defined image klicken und den Titel ändern. Danke Dir!

Viele Grüße,
Christian

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Jakob_Ullmann
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1747
Erhaltene Danke: 15

Win 7, *Ubuntu GNU/Linux*
*Anjuta* (C, C++, Python), Geany (Vala), Lazarus (Pascal), Eclipse (Java)
BeitragVerfasst: Mo 02.06.08 15:19 
Was meinst du mit einem digitalen Würfel?

PS: Es geht auch kürzer:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
var x: integer;
begin
  randomize;
  x:=random(6)+1;
  TShape(FindComponent('Shape' + IntToStr(x))).Brush.Color := clBlack;
  readln;
end;
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: Mo 02.06.08 15:22 
Hallo!

Na einen Würfel, der würfelt..am Computer..eben digital ;-)

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.
platzwart
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1054
Erhaltene Danke: 78

Win 7, Ubuntu 9.10
Delphi 2007 Pro, C++, Qt
BeitragVerfasst: Mo 02.06.08 15:25 
aber was soll dann das "readln"?!? und vlt auch die farbe der shapes bei jedem durchlauf zurücksetzen...
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: Mo 02.06.08 15:38 
Das hat da drin nix verloren...

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.
Jakob_Ullmann
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1747
Erhaltene Danke: 15

Win 7, *Ubuntu GNU/Linux*
*Anjuta* (C, C++, Python), Geany (Vala), Lazarus (Pascal), Eclipse (Java)
BeitragVerfasst: Mo 02.06.08 16:05 
Achso. Ich hab jetzt nicht an den Spielwürfel gedacht. Mehr daran, mit Canvas einen Würfel als Schrägbild zu zeichnen. :wink: Also zum Zeichnen: Am besten ohne Shapes

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
var
  zufall: Integer;
begin
  randomize;
  zufall := random(6) + 1;
  Canvas.Pen.Color   := clBlack;
  Canvas.Brush.Color := clBlack;
  Canvas.Rectangle(10 + zufall * 3010030 + zufall * 30120); // Rechteck zeichnen
end;
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10184
Erhaltene Danke: 1259

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 02.06.08 16:23 
Moin!

Ich schätze, das sind die Augen von dem Würfel (sollten dann allerdings 7 sein... :gruebel:), die dann halt passend gefärbt werden sollen. :idea:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Jakob_Ullmann
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1747
Erhaltene Danke: 15

Win 7, *Ubuntu GNU/Linux*
*Anjuta* (C, C++, Python), Geany (Vala), Lazarus (Pascal), Eclipse (Java)
BeitragVerfasst: Mo 02.06.08 16:35 
Wieso sollten es sieben sein?
Nico72
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 50

Win XP, Vista
Delphi 7, Delphi 2006
BeitragVerfasst: Mo 02.06.08 16:42 
Na 6 am Rand und einer in der Mitte
Jakob_Ullmann
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1747
Erhaltene Danke: 15

Win 7, *Ubuntu GNU/Linux*
*Anjuta* (C, C++, Python), Geany (Vala), Lazarus (Pascal), Eclipse (Java)
BeitragVerfasst: Mo 02.06.08 17:06 
Achso. :shock: Dann vielleicht so?

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:
var
  augen: array[1..61..7of Boolean;
  zufall, i: Integer;
begin
  // Erstens
  augen[1][1] := False;
  augen[1][2] := False;
  augen[1][3] := False;
  augen[1][4] := False;
  augen[1][5] := False;
  augen[1][6] := False;
  augen[1][7] := True;
  // Zweitens
  augen[2][1] := True;
  augen[2][2] := False;
  augen[2][3] := False;
  augen[2][4] := False;
  augen[2][5] := False;
  augen[2][6] := True;
  augen[2][7] := False;
  // Drittens
  augen[3][1] := True;
  augen[3][2] := False;
  augen[3][3] := False;
  augen[3][4] := False;
  augen[3][5] := False;
  augen[3][6] := True;
  augen[3][7] := True;
  // Viertens
  augen[4][1] := True;
  augen[4][2] := True;
  augen[4][3] := False;
  augen[4][4] := False;
  augen[4][5] := True;
  augen[4][6] := True;
  augen[4][7] := False;
  // Fünftens
  augen[5][1] := True;
  augen[5][2] := True;
  augen[5][3] := False;
  augen[5][4] := False;
  augen[5][5] := True;
  augen[5][6] := True;
  augen[5][7] := True;
  // Sechstens
  augen[6][1] := True;
  augen[6][2] := True;
  augen[6][3] := True;
  augen[6][4] := True;
  augen[6][5] := True;
  augen[6][6] := True;
  augen[6][7] := False;
  // Würfeln
  randomize;
  zufall := random(6) + 1;
  // Malen
  for i := 1 to 7 do
  begin
    if augen[zufall][i] = True then
      TShape(FindComponent('Shape' + IntToStr(i))).Brush.Color := clBlack
    else TShape(FindComponent('Shape' + IntToStr(i))).Brush.Color := clWhite;
  end;
end;
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10184
Erhaltene Danke: 1259

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 02.06.08 17:34 
Moin!

user profile iconJakob_Ullmann hat folgendes geschrieben:
Achso. :shock: Dann vielleicht so?
Bischen aufwändig, oder? ;) Vorschlag: :idea:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
//  1   2
//  3 7 4
//  5   6
procedure TForm1.Button1Click(Sender: TObject);
  type
    TAugen = set of 1..6;
  const
    Stati: array[1..7of TAugen = ( [2..6],[4..6],[6],[6],[4..6],[2..6],[1,3,5] );
    Color: array[Boolean] of TColor = ( clWhite, clBlack );
  var
    Wurf, i: Integer;
begin
  Wurf := Random(6) +1;
  Button1.Caption := IntToStr(Wurf);
  for i := 1 to 7 do
    TShape(FindComponent('Shape'+IntToStr(i))).Brush.Color := Color[Wurf in Stati[i]];
end;
cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Mo 02.06.08 17:44 
Der Threadsteller hat noch nicht einmal reagiert.. und ihr liefet fertige Quelltexte ab? :shock:

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10184
Erhaltene Danke: 1259

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 02.06.08 17:47 
Moin!

user profile iconHidden hat folgendes geschrieben:
Der Threadsteller hat noch nicht einmal reagiert.
Nun, er hat immerhin um kurz nach 5 den Titel geändert... :?

user profile iconHidden hat folgendes geschrieben:
und ihr liefet fertige Quelltexte ab? :shock:
Tja, was soll ich dazu sagen, glücklich bin ich auch nicht drüber :| aber ich habe (und hätte) auch nicht damit "angefangen"... :P :lol:

Freut mich aber, dass jemand anders auch mal was dazu sagt! :zustimm:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Mo 02.06.08 18:04 
Hi,

ausblenden Delphi-Quelltext
1:
if augen[zufall][i] = True then					

Bitte niemals auf Suche in der Entwickler-Ecke TRUE VERGLEICHen. Danke!

mfG,

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)
Guenther A.
Hält's aus hier
Beiträge: 5



BeitragVerfasst: Mo 02.06.08 21:11 
Wo werden den die anderen Punkte weiß gefärbt? (oder auch in anderer Farbe.)

Mein Ansatz wäre sinngemäß
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
gewuerfeltezahl:=....  
For Nr:= 1 to 6 do 
  begin
  if Nr=gewuerfeltezahl then
     .... black
  else
     .... white
  end;

Je nach Komponente für die gezeichneten Kreise wird dann auch noch ein invalidate oder einfache refresh gebraucht.

Gruß Guenther

Moderiert von user profile iconNarses: Delphi-Tags hinzugefügt und Frage aus dem Titel in den Text verschoben
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: Mo 02.06.08 21:48 
Das macht ja keinen Sinn, denn guck dir mal einen Würfel an. Da sind mehr als nur ein Punkt schwarz gefärbt (mit Außnahme der Eins natürlich ;-) ).

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
Cano Threadstarter
Hält's aus hier
Beiträge: 6



BeitragVerfasst: Di 03.06.08 14:06 
Titel: gracias
Danke für die guten Vorschläge, aber wir verstehen das irgendwie nicht.

Wir wollten eigentlich, dass sich jeweils nur ein Kreis anders färbt, wenn wir auf "würfeln" drücken. Aber es funktioniert nicht.

Wir sind verzweifelt! :autsch:
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: Di 03.06.08 14:11 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
var i: Integer;
begin;
 //Alle Shapes weiß
 for i:= 1 to 6 do
  TShape(FindComponent('Shape'+IntToStr(i))).Brush.Color:= clwhite;

 //Zufällige Zahl;
 x:= random(6)+1;

 //Shape anmalen
 TShape(FindComponent('Shape'+IntToStr(x))).Brush.Color:= clBlack;
end;

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.