Sorry about missing the deadline - I checked the last post in the thread and there wasn't any 'Time's up - no more entries' post from the judge before I posted. (If the judge doesn't call a halt to the challenge for any reason anyone can take advantage of the extra time).
OK, I here's the the challenge...
You have to write a program which uses the following function MakeDice():
Function MakeDice(NumDice,StartObjNumber,DiceSize#)
Create Bitmap 1,800,600
CLS RGB(85,0,0)
Rem Number One
Ink RGB(255,0,0),0: Box 2,2,254,254
Ink RGB(255,255,255),0
For N=1 To 24
Circle 128,128,N: Circle 128,129,N
Next N
Get Image 1001,0,0,256,256
Rem Number Two
Ink RGB(255,0,0),0: Box 2,2,254,254
Ink RGB(255,255,255),0
For N=1 To 24
Circle 46,46,N: Circle 46,47,N
Circle 208,208,N: Circle 208,209,N
Next N
Get Image 1002,0,0,256,256
Rem Number Three
Ink RGB(255,0,0),0: Box 2,2,254,254
Ink RGB(255,255,255),0
For N=1 To 24
Circle 46,46,N: Circle 46,47,N
Circle 128,128,N: Circle 128,129,N
Circle 208,208,N: Circle 208,209,N
Next N
Get Image 1003,0,0,256,256
Rem Number Four
Ink RGB(255,0,0),0: Box 2,2,254,254
Ink RGB(255,255,255),0
For N=1 To 24
Circle 46,46,N: Circle 46,47,N
Circle 208,46,N: Circle 208,47,N
Circle 46,208,N: Circle 46,209,N
Circle 208,208,N: Circle 208,209,N
Next N
Get Image 1004,0,0,256,256
Rem Number Five
Ink RGB(255,0,0),0: Box 2,2,254,254
Ink RGB(255,255,255),0
For N=1 To 24
Circle 46,46,N: Circle 46,47,N
Circle 208,46,N: Circle 208,47,N
Circle 128,128,N: Circle 128,129,N
Circle 46,208,N: Circle 46,209,N
Circle 208,208,N: Circle 208,209,N
Next N
Get Image 1005,0,0,256,256
Rem Number Six
Ink RGB(255,0,0),0: Box 2,2,254,254
Ink RGB(255,255,255),0
For N=1 To 24
Circle 46,46,N: Circle 46,47,N
Circle 208,46,N: Circle 208,47,N
Circle 46,128,N: Circle 46,129,N
Circle 208,128,N: Circle 208,129,N
Circle 46,208,N: Circle 46,209,N
Circle 208,208,N: Circle 208,209,N
Next N
Get Image 1006,0,0,256,256
Set Current Bitmap 0
Delete Bitmap 1
For ObjNum = StartObjNumber To StartObjNumber+(NumDice-1)
Offset#=DiceSize#/2.0: MeshNum=2000: PlainNum=2000
Make Object Cube ObjNum,DiceSize#
Make Object Plain PlainNum,DiceSize#,DiceSize#
Make Mesh From Object MeshNum,PlainNum
ADD LIMB ObjNum,1,2000: Offset Limb ObjNum,1,0,0,0.0-Offset#: Rem Cube Side 1 (Front)
ADD LIMB ObjNum,2,2000: Rotate Limb ObjNum,2,0,90,0: Offset Limb ObjNum,2,0.0-Offset#,0,0: Rem Cube Side 2 (Left)
ADD LIMB ObjNum,3,2000: Rotate Limb ObjNum,3,0,180,0: Offset Limb ObjNum,3,0,0,Offset#: Rem Cube Side 3 (Back)
ADD LIMB ObjNum,4,2000: Rotate Limb ObjNum,4,0,270,0: Offset Limb ObjNum,4,Offset#,0,0: Rem Cube Side 4 (Right)
ADD LIMB ObjNum,5,2000: Rotate Limb ObjNum,5,270,0,0: Offset Limb ObjNum,5,0,0.0-Offset#,0: Rem Cube Side 5 (Bottom)
ADD LIMB ObjNum,6,2000: Rotate Limb ObjNum,6,90,0,0: Offset Limb ObjNum,6,0,Offset#,0: Rem Cube Side 6 (Top)
Delete Mesh MeshNum
Delete Object PlainNum
Hide Limb ObjNum,0
Texture LIMB ObjNum,1,1005: Texture LIMB ObjNum,2,1006
Texture LIMB ObjNum,3,1002: Texture LIMB ObjNum,4,1001
Texture LIMB ObjNum,5,1003: Texture LIMB ObjNum,6,1004
Next ObjNum
EndFunction
Using The Function
The function takes three parameters:
NumDice (integer) - this is the number of dice objects you want to create.
StartObjNumber (integer) - this is the object number of the first dice. The rest of the dice will have consecutive object numbers.
DiceSize# (float) - this is the required size of the dice.
So, if you use
MakeDice(3,100,2.5)
you will get 3 dice, the first one being object number 100, the second 101 and the third 102. Each dice will be 2.5 3D units in size.
Objectives:
* You can write a full game or just a demo.
* You can use as many dice as you wish.
Challenge closes: 20th October at midnight GMT (Saturday Night).
Example Skeleton Program:
Below is an empty skeleton program you can use to start your own entry. It contains only the function, a setup procedure (the section you can alter is marked) and a very rough procedure which displays the dice (which you can remove).
Rem DBC Programming Challenges
Rem Dice Challenge
Rem By:
Gosub Setup
Do
Rem Main Program Loop
Gosub TestDice
Sync
Loop
End
Rem ****************************************************************************************************
Rem *** Procedures ***
Rem ****************************************************************************************************
Setup:
Set Display Mode 800,600,32
AutoCam Off
Sync On
Sync Rate 0
CLS 0
Randomize Timer()
True = 1: False = 0
Dim DScore(6)
Rem ********************************************************************************
Rem Alter/delete this section as required...
MakeDice(6,1,1.0): Rem Make 6 dice - the first one being object 1 - with the size 1.0
Position Object 1,-3.75,0,0
Position Object 2,-2.25,0,0
Position Object 3,-0.75,0,0
Position Object 4,0.75,0,0
Position Object 5,2.25,0,0
Position Object 6,3.75,0,0
Rem ********************************************************************************
Position Camera 0,0,-10
Return
TestDice:
Rem Remove for your own program
Center Text 400,0,"Press Space To Stop/Start Dice Rolling"
If Trigger=False
For N=1 To 6
R = Rnd(3)*10
XRotate Object N,WrapValue(Object Angle X(N)+R)
YRotate Object N,WrapValue(Object Angle Y(N)+R)
Next N
Else
If DiceStopped = False
For N=1 To 6
DScore(N)=Rnd(5)+1: Rem Random dice face chosen
Select DScore(N)
Case 1: Rotate Object N,0,90,0: EndCase
Case 2: Rotate Object N,0,180,0: EndCase
Case 3: Rotate Object N,90,0,0: EndCase
Case 4: Rotate Object N,270,0,0: EndCase
Case 5: Rotate Object N,0,0,0: EndCase
Case 6: Rotate Object N,0,270,0: EndCase
EndSelect
Next N
DiceStopped = True
Endif
Endif
Rem Reak Space bar
If Inkey$()=" "
If Trigger=False
Trigger=True
Else
Trigger=False
DiceStopped = False
Endif
Repeat
Until Inkey$()=""
Endif
Return
Rem ****************************************************************************************************
Rem *** Functions ***
Rem ****************************************************************************************************
Function MakeDice(NumDice,StartObjNumber,DiceSize#)
Create Bitmap 1,800,600
CLS RGB(85,0,0)
Rem Number One
Ink RGB(255,0,0),0: Box 2,2,254,254
Ink RGB(255,255,255),0
For N=1 To 24
Circle 128,128,N: Circle 128,129,N
Next N
Get Image 1001,0,0,256,256
Rem Number Two
Ink RGB(255,0,0),0: Box 2,2,254,254
Ink RGB(255,255,255),0
For N=1 To 24
Circle 46,46,N: Circle 46,47,N
Circle 208,208,N: Circle 208,209,N
Next N
Get Image 1002,0,0,256,256
Rem Number Three
Ink RGB(255,0,0),0: Box 2,2,254,254
Ink RGB(255,255,255),0
For N=1 To 24
Circle 46,46,N: Circle 46,47,N
Circle 128,128,N: Circle 128,129,N
Circle 208,208,N: Circle 208,209,N
Next N
Get Image 1003,0,0,256,256
Rem Number Four
Ink RGB(255,0,0),0: Box 2,2,254,254
Ink RGB(255,255,255),0
For N=1 To 24
Circle 46,46,N: Circle 46,47,N
Circle 208,46,N: Circle 208,47,N
Circle 46,208,N: Circle 46,209,N
Circle 208,208,N: Circle 208,209,N
Next N
Get Image 1004,0,0,256,256
Rem Number Five
Ink RGB(255,0,0),0: Box 2,2,254,254
Ink RGB(255,255,255),0
For N=1 To 24
Circle 46,46,N: Circle 46,47,N
Circle 208,46,N: Circle 208,47,N
Circle 128,128,N: Circle 128,129,N
Circle 46,208,N: Circle 46,209,N
Circle 208,208,N: Circle 208,209,N
Next N
Get Image 1005,0,0,256,256
Rem Number Six
Ink RGB(255,0,0),0: Box 2,2,254,254
Ink RGB(255,255,255),0
For N=1 To 24
Circle 46,46,N: Circle 46,47,N
Circle 208,46,N: Circle 208,47,N
Circle 46,128,N: Circle 46,129,N
Circle 208,128,N: Circle 208,129,N
Circle 46,208,N: Circle 46,209,N
Circle 208,208,N: Circle 208,209,N
Next N
Get Image 1006,0,0,256,256
Set Current Bitmap 0
Delete Bitmap 1
For ObjNum = StartObjNumber To StartObjNumber+(NumDice-1)
Offset#=DiceSize#/2.0: MeshNum=2000: PlainNum=2000
Make Object Cube ObjNum,DiceSize#
Make Object Plain PlainNum,DiceSize#,DiceSize#
Make Mesh From Object MeshNum,PlainNum
ADD LIMB ObjNum,1,2000: Offset Limb ObjNum,1,0,0,0.0-Offset#: Rem Cube Side 1 (Front)
ADD LIMB ObjNum,2,2000: Rotate Limb ObjNum,2,0,90,0: Offset Limb ObjNum,2,0.0-Offset#,0,0: Rem Cube Side 2 (Left)
ADD LIMB ObjNum,3,2000: Rotate Limb ObjNum,3,0,180,0: Offset Limb ObjNum,3,0,0,Offset#: Rem Cube Side 3 (Back)
ADD LIMB ObjNum,4,2000: Rotate Limb ObjNum,4,0,270,0: Offset Limb ObjNum,4,Offset#,0,0: Rem Cube Side 4 (Right)
ADD LIMB ObjNum,5,2000: Rotate Limb ObjNum,5,270,0,0: Offset Limb ObjNum,5,0,0.0-Offset#,0: Rem Cube Side 5 (Bottom)
ADD LIMB ObjNum,6,2000: Rotate Limb ObjNum,6,90,0,0: Offset Limb ObjNum,6,0,Offset#,0: Rem Cube Side 6 (Top)
Delete Mesh MeshNum
Delete Object PlainNum
Hide Limb ObjNum,0
Texture LIMB ObjNum,1,1005: Texture LIMB ObjNum,2,1006
Texture LIMB ObjNum,3,1002: Texture LIMB ObjNum,4,1001
Texture LIMB ObjNum,5,1003: Texture LIMB ObjNum,6,1004
Next ObjNum
EndFunction
TDK_Man