Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Led-libary TextLCD mbed
Fork of Laufled by
Diff: main.cpp
- Revision:
- 10:f635972952e0
- Parent:
- 9:cb931ad9731d
- Child:
- 11:caa67a0ab7bd
--- a/main.cpp Sat Mar 12 23:26:51 2016 +0000
+++ b/main.cpp Sun Mar 13 00:18:29 2016 +0000
@@ -33,6 +33,7 @@
void DiceRun();
void setDice(char number);
void DicePrint();
+void DiceCal(); //umrechning des 7.Zustands in eine Zahl zwischen 1 & 6
char dicePos = 0;
char diceEn = 0;
char diceTick = 0;
@@ -73,6 +74,7 @@
char AnimPos[Spieler*Steine];
char AnimDo; //Feld_Animieren,Start Animieren, Ziel Animierenw
void AnimCal();
+void reset();
void reset()
{
@@ -141,6 +143,7 @@
FeldPrint();
GameCal();
*/
+ /*
port.printf("W%c%c\n",27+0x3E,27+0x7);
for(char i=0;i<Spieler;i++)
{
@@ -148,6 +151,8 @@
ColorPrint(Farben[i]);
wait(1);
}
+ */
+ diceEn=5;
}
void btn4()
@@ -305,46 +310,17 @@
diceNum = (RandomDice.read_us()+diceNum)%7+1;
RandomDice.stop();
RandomDice.reset();
- if(diceNum==7)
- {
- diceEn=3;
- for(char i = 0;i<Steine;i++)
- if((PlayPos[(Drann<<2)|i]>Steine -1)&&(PlayPos[(Drann<<2)|i] < Steine + Feldgrose*Spieler))
- for(char j = 1;j<=6;j++)
- {
- char temp = Field[(PlayPos[(Drann<<2)|i]- Steine + Feldgrose * Drann+j) % (Feldgrose*Steine)];
- if(temp>0)
- {
- temp--; //(Spieler<<2)|Stein
- temp = (temp&0xC)>>2;//Spieler
- if(temp!=Drann)
- if(j<diceNum)
- diceNum=j;
- }
- }
- //PlayPos[(Drann<<2)|i] im Feld suchen, weiter setzen, wenn treffer, der kleiner als diceNum ->setzen von diceNum
- }//DiceNum == 7
- if(diceNum==7)
- diceNum=6;
- port.printf("LDiceNum:%d\n",diceNum);
+ if(diceNum>=7)
+ DiceCal();
+ //port.printf("LDiceNum:%d\n",diceNum);
DicePrint();
GameCal();
}
}
}
-void setDice(char number)
+void DiceCal()
{
- port.printf("LdiceEn:%d\n",diceEn);
- if(diceEn==1)
- {
- DiceAnim.detach();
- diceTick = 0;
- RandomDice.stop();
- RandomDice.reset();
- }
- diceEn = 2;
- diceNum = number;
if(diceNum>7)
diceNum=7;
if(diceNum==7)
@@ -368,9 +344,36 @@
}//DiceNum == 7
if(diceNum==7)
diceNum=6;
- port.printf("LForceDice:%d\n",diceNum);
- DicePrint();
- GameCal();
+ port.printf("LdiceNum:%d\n",diceNum);
+}
+
+void setDice(char number)
+{
+ if(diceEn==4)
+ {
+ port.printf("LWarning: diceEn:%d -> Game over\n",diceEn);
+ }
+ else
+ {
+ if(diceEn>3)
+ port.printf("LWarning: diceEn:%d\n",diceEn);
+ else
+ port.printf("LdiceEn:%d\n",diceEn);
+ if(diceEn==1)
+ {
+ DiceAnim.detach();
+ diceTick = 0;
+ RandomDice.stop();
+ RandomDice.reset();
+ }
+ diceEn = 2;
+ diceNum = number;
+ if(diceNum>=7)
+ DiceCal();
+ //port.printf("LForceDice:%d\n",diceNum);
+ DicePrint();
+ GameCal();
+ }
}
void DiceRun()
