Post by PeterMaria on Mar 4, 2011 12:08:26 GMT -5
Hi,
here is a little game for you, named Magic Square.
The aim of the game is to get all numbers in this regulation.
o1 o2 o3 o4
o5 o6 o7 o8
o9 10 11 12
13 14 15
this will win !
the handling is very easy to do.
just click simply on a number.
This is especially for my friends: Matthew, Tom Mulgrew and our Galaxy. ;D
here is a little game for you, named Magic Square.
The aim of the game is to get all numbers in this regulation.
o1 o2 o3 o4
o5 o6 o7 o8
o9 10 11 12
13 14 15
this will win !
the handling is very easy to do.
just click simply on a number.
This is especially for my friends: Matthew, Tom Mulgrew and our Galaxy. ;D
TextMode(TEXT_BUFFERED)
ResizeSpriteArea(254,336)
Dim xPos,yPos,x,y,j,n,m,num(14),a,i,jx,bac
Dim moves,click,wons,crn,won,clic,blu,fnt(62)
Dim Map(40)
Dim Buf(16)
For j=0 To 40
Map(j) =255
Next
Num = LoadTexStrip("media/numbers.png",64,64)
fnt = LoadTexStrip("media/fontstrip.png",16,16)
crn = LoadTex("media/crown.png")
bac = LoadTex("media/back.png")
wons = LoadSound("media/won.wav")
clic = LoadSound("media/clic.wav")
Function Rand(min, max)
Return rnd() % (max-min+1) + min
End Function
Sub Sprite(nr(),x5,y5,w5,h5,frame)
NewSprite(nr)
SprSetxCentre(0):SprSetyCentre(0)
SprSetZOrder(1)
SprSetSize(w5,h5)
SprSetPos (x5,y5)
SprSetFrame(frame)
End Sub
Sub Bitmap(Hnd,x1,y1,w1,h1)
NewSprite(Hnd)
SprSetxCentre(0):SprSetyCentre(0)
SprSetZOrder(1)
SprSetSize(w1,h1)
SprSetPos (x1,y1)
End Sub
Sub Text(txt$,x4,y4,w4,h4)
Dim sxx, jxx, pxx
sxx = Len(txt$)
For jxx =1 To sxx
pxx = Asc(Mid$(txt$,jxx,1))
iF pxx >=32 And pxx <=90 Then
pxx = pxx -32
Sprite(fnt,x4,y4,w4,h4,pxx)
x4 = x4 + w4
End iF
Next
End Sub
Sub MousePosition(bydiv)
xPos = Mouse_X()*254
yPos = Mouse_Y()*336
xPos = xPos /bydiv
yPos = yPos /bydiv
End Sub
Sub CheckWon()
iF Won =1 Then: Return: End iF
Dim jx =0
For y=0 To 3
For x=0 To 3
j= y*4 + x
jx = j +1
iF jx =16 Then: jx =0: End iF
iF Map(j) <> jx Then: Return: End iF
Next
Next
PlaySound(wons)
won =1
End Sub
Sub PushNumber()
iF Mouse_Button(Mouse_LButton) and click =0 and won =0 Then
MousePosition(64)
j = yPos*4 + xPos
iF Map(j) =0 or yPos >3 Then: Return: End iF
iF Map(j+1) =0 and click =0 Then
Map(j+1) = Map(j)
Map(j) =0: moves = moves +1
click =1
PlaySound(clic)
ElseiF xPos >0 land Map(j-1) =0 and click =0 Then
Map(j-1) = Map(j)
Map(j) =0: moves = moves +1
click =1
PlaySound(clic)
ElseiF yPos >0 land Map(j-4) =0 and click =0 Then
Map(j-4) = Map(j)
Map(j) =0: moves = moves +1
click =1
PlaySound(clic)
ElseiF Map(j+4) =0 and click =0 Then
Map(j+4) = Map(j)
Map(j) =0: moves = moves +1
click =1
PlaySound(clic)
EndiF
EndiF
End Sub
Sub ShowMap()
For y=0 To 3
For x=0 To 3
j= y*4 + x
iF Map(j) =16 Then
Map(j) =0
ElseiF Map(j) >=1 and Map(j) <=15 Then
Sprite(num,x*64,y*64,64,64,Map(j)-1)
EndiF
Next
Next
End Sub
Sub CheckBuffer()
a = Rand(1,16)
For m=0 To 15
iF Buf(m) =a Then: Return: End iF
Next
Buf(n) =a
n = n +1
End Sub
Sub SetNumber()
n =0
While n < 16
CheckBuffer()
Wend
For y=0 To 3
For x=0 To 3
j= y*4 + x
Map(j) = Buf(j)
Next: Next
End Sub
Sub NewGame()
MousePosition(16)
iF Mouse_Button(Mouse_LButton)and click =0 Then
iF xPos >=7 and xPos <=9 and yPos >=16 and yPos <=17 Then
moves =0: won =0
click =1
For i=0 To 16
Buf(i) =0
Next
For y=0 To 3
For x=0 To 3
j= y*4 + x
Map(j) =0
Next
Next
SetNumber()
End iF
End iF
End Sub
Cls
Bitmap(bac,0,0,254,336)
Bitmap(crn,0,0,256,256)
Text("DON'T BE A KING!",2,258,16,24)
Text(" SPACE BAR ",2,284,16,22)
While Not ScanKeyDown(vk_space)
DrawText()
Wend
SetNumber()
While (1)
Bitmap(bac,0,0,254,336)
ShowMap()
NewGame()
PushNumber()
CheckWon()
Text("NEW",107,260,16,24)
Text("MOVES " + moves,91,284,16,24)
DrawText()
ClearSprites()
WaitTimer(10)
iF Not Mouse_Button(Mouse_LButton) Then: click =0: End iF
Wend