' Pelmanism (Pairs) Game version 2 by QWERKEY 2019-01-05
' Images from openclipart.org,clipartpng.com & pngimg.com
' Sounds from findsounds.com
CONST True
= -1`
, False
= 0`
CONST NoObjectsLess1%%
= 67 DIM BestScore%
(2), GameLevel%%
(2, 1), NosImg&
(9, 1), Images&
(NoObjectsLess1%%
)
READ GameLevel%%
(N%%
, M%%
) 'Create Images
DATA Bananas
,Cherry
,Carrots
,Pepper
,Tomato
,Cat
,Egg
,Beer
,Acorn
,Feather
,Squirrel
,IcedBun
,LightBulb
,GoldCup
DATA Parrot
,LadyMouse
,Mushrooms
,Pineapple
,Balloons
,Rose
,CloverLeaf
,Goose
,Raccoon
,Raspberry
,Violin
,TeddyBear
DATA Clock
,Shoes
,Wrench
,Hammer
,Computer
,Matches
,Diamond
,WineGlass
,Frog
,Chimp
,Apricot
,RollsRoyce
,Knight
,Bee
DATA Fish
,IceCream
,SnowFlake
,XmasTree
,Butterfly
,Rainbow
,Penguin
,Fox
,Hummingbird
,Cashews
,Tulips
,Matryoshka
DATA Lion
,Apple
,Hat
,Heart
,Key1
,Ladybird
,Strawberry
,TV
,Dog
,Dolphin
,Koala
,Earth
,Olives
,Einstein
,Plane
,Flag
FOR N%%
= 0 TO NoObjectsLess1%%
NosImg&(N%%, 1) = MakeHardware&(TempImg&)
NosImg&(N%%, 0) = MakeHardware&(TempImg&)
BestImg& = MakeHardware&(TempImg&)
'Load/Set Initial Data
INPUT #1, BestScore%
(N%%
) SelectButton
'CALL UseUpMouse
'Perform Game
Pelmanism` = True
GetSkillLevel
OldButton
= _MOUSEBUTTON(ButtonNo%%
) 'Get the current mouse state to make certain the user lifted it up after selecting the skill level 'Do Puzzle
XLimit% = 57 + (GameLevel%%(Level%%, 0) - 1) * 107 + 45
YLimit% = 57 + (GameLevel%%(Level%%, 1) - 1) * 107 + 45
IsComplete` = False
Score% = 0
NoRemaining%% = GameLevel%%(Level%%, 0) * GameLevel%%(Level%%, 1)
NoPairs%% = 0
FirstV%% = 50
ValidMouse` = False
Flipping` = False
TurningBack` = False
FlipCount%% = 0
Paused` = False
PCount%% = 0
FirstGo` = True
REDIM Motion`
(10, 6, 2), Selected%%
(30), Choisi`
(10, 6), Grid%%
(10, 6) Vacant` = False
HorizPos%%
= 1 + INT(GameLevel%%
(Level%%
, 0) * RND) VertPos%%
= 1 + INT(GameLevel%%
(Level%%
, 1) * RND) IF Grid%%
(HorizPos%%
, VertPos%%
) = 0 THEN Vacant`
= True
NewPair` = False
PairNo%%
= 1 + INT(NoObjectsLess1%%
* RND) PairsExists` = False
N%% = 1
IF PairNo%%
= Selected%%
(N%%
) THEN PairsExists`
= True
N%% = N%% + 1
NoPairs%% = NoPairs%% + 1
Selected%%(NoPairs%%) = PairNo%%
Grid%%(HorizPos%%, VertPos%%) = PairNo%%
Vacant` = False
HorizPos%%
= 1 + INT(GameLevel%%
(Level%%
, 0) * RND): VertPos%%
= 1 + INT(GameLevel%%
(Level%%
, 1) * RND) IF Grid%%
(HorizPos%%
, VertPos%%
) = 0 THEN Vacant`
= True
Selected%%(NoPairs%%) = PairNo%%
Grid%%(HorizPos%%, VertPos%%) = PairNo%%
NoRemaining%% = NoRemaining%% - 2
NoRemaining%% = GameLevel%%(Level%%, 0) * GameLevel%%(Level%%, 1)
TempImg&
= _NEWIMAGE(205 + XLimit%
, YLimit%
+ 12, 32) FOR N%%
= 0 TO GameLevel%%
(Level%%
, 0) - 1 FOR M%%
= 0 TO GameLevel%%
(Level%%
, 1) - 1 LINE (3 + N%%
* 107, 3 + M%%
* 107)-(3 + (N%%
+ 1) * 107, 3 + (M%%
+ 1) * 107), , B
Background& = MakeHardware&(TempImg&)
LINE (0, 0)-(103, 103), , B
LINE (1, 1)-(102, 102), , B
Highlight& = MakeHardware&(TempImg&)
LINE (0, 0)-(143, 51), , B
Quitlight& = MakeHardware&(TempImg&)
IF BestScore%
(Level%%
) <> 0 THEN IF BestScore%
(Level%%
) <= 9 THEN _PUTIMAGE (XLimit%
+ 140, 60), NosImg&
(BestScore%
(Level%%
), 1) _PUTIMAGE (XLimit%
+ 140, 60), NosImg&
(BestScore%
(Level%%
) \
10, 1) _PUTIMAGE (XLimit%
+ 160, 60), NosImg&
(BestScore%
(Level%%
) MOD 10, 1) _PUTIMAGE (XLimit%
+ 140, 185), NosImg&
(Score%
, 0) _PUTIMAGE (XLimit%
+ 140, 185), NosImg&
(Score% \
10, 0) MouseClick` = False
ValidMouse` = False
QuitMouse` = False
IF XMouse%
> 7 AND XMouse%
< (GameLevel%%
(Level%%
, 0)) * 107 AND YMouse%
> 7 AND YMouse%
< (GameLevel%%
(Level%%
, 1)) * 107 THEN ValidMouse` = True
XX%% = (XMouse% - 7) \ 107
YY%% = (YMouse% - 7) \ 107
XHighLight% = 5 + 107 * XX%%
YHighLight% = 5 + 107 * YY%%
ELSEIF XMouse%
> XLimit%
+ 35 AND XMouse%
< XLimit%
+ 169 AND YMouse%
> 355 AND YMouse%
< 397 THEN QuitMouse` = True
XHighLight% = XLimit% + 30
YHighLight% = 350
IF XMouse%
> XLimit%
+ 35 AND XMouse%
< XLimit%
+ 169 AND YMouse%
> 355 AND YMouse%
< 397 THEN DoGrid`
= False
IF ValidMouse`
THEN MouseClick`
= True
OldButton
= _MOUSEBUTTON(ButtonNo%%
) 'store whether mouse was up or down last
_PUTIMAGE (XHighLight%
, YHighLight%
), Highlight&
_PUTIMAGE (XHighLight%
, YHighLight%
), Quitlight&
FOR HorizPos%%
= 1 TO GameLevel%%
(Level%%
, 0) FOR VertPos%%
= 1 TO GameLevel%%
(Level%%
, 1) IF Motion`
(HorizPos%%
, VertPos%%
, 2) THEN 'Turn back
_PUTIMAGE (107 * (HorizPos%%
- 1) + 7, 107 * (VertPos%%
- 1) + 7), Images&
(Grid%%
(HorizPos%%
, VertPos%%
)) 'Fronts PCount%% = PCount%% + 1
Paused` = False
PCount%% = 0
XPos% = 107 * (HorizPos%% - 1) + 7
YPos% = 107 * (VertPos%% - 1) + 7
_PUTIMAGE (FlipCount%%
+ XPos%
, YPos%
)-(XPos%
+ 100 - FlipCount%%
, YPos%
+ 100), Images&
(Grid%%
(HorizPos%%
, VertPos%%
)) _PUTIMAGE (XPos%
+ FlipCount%%
, YPos%
)-(XPos%
+ 100 - FlipCount%%
, YPos%
+ 100), ObverseImg&
FlipCount%% = FlipCount%% + 1
FlipCount%% = 0
IF HorizPos%%
= FirstH%%
AND VertPos%%
= FirstV%%
THEN Motion`(HorizPos%%, VertPos%%, 2) = False
Motion`(HorizPos%%, VertPos%%, 0) = False
Flipping` = False
TurningBack` = False
FirstV%% = 50
'CALL UseUpMouse
Motion`(HorizPos%%, VertPos%%, 2) = False
Motion`(HorizPos%%, VertPos%%, 0) = False
Motion`(FirstH%%, FirstV%%, 2) = True
'Turn forward
XPos% = 107 * (HorizPos%% - 1) + 7
YPos% = 107 * (VertPos%% - 1) + 7
_PUTIMAGE (XPos%
+ 100 - FlipCount%%
, YPos%
)-(XPos%
+ FlipCount%%
, YPos%
+ 100), ObverseImg&
_PUTIMAGE (100 - FlipCount%%
+ XPos%
, YPos%
)-(XPos%
+ FlipCount%%
, YPos%
+ 100), Images&
(Grid%%
(HorizPos%%
, VertPos%%
)) FlipCount%% = FlipCount%% + 1
FlipCount%% = 0
Flipping` = False
Motion`(HorizPos%%, VertPos%%, 1) = False
Motion`(HorizPos%%, VertPos%%, 0) = True
FirstGo` = False
FirstGo` = True
IF Grid%%
(HorizPos%%
, VertPos%%
) = Grid%%
(FirstH%%
, FirstV%%
) THEN 'Matched pair Choisi`(HorizPos%%, VertPos%%) = True 'Registers that that grid position cannot be clicked any more
Choisi`(FirstH%%, FirstV%%) = True
NoRemaining%% = NoRemaining%% - 2
'Tah-dah sound (completed)
'Ching sound (match)
'Initiate sequential turn back
Motion`(HorizPos%%, VertPos%%, 2) = True
Flipping` = True
TurningBack` = True
Paused` = True
PCount%% = 0
IF Score%
< 99 THEN Score%
= Score%
+ 1 'Pairings Completed
IF Score%
< BestScore%
(Level%%
) OR BestScore%
(Level%%
) = 0 THEN BestScore%
(Level%%
) = Score%
'CALL UseUpMouse
_PUTIMAGE (107 * (HorizPos%%
- 1) + 7, 107 * (VertPos%%
- 1) + 7), Images&
(Grid%%
(HorizPos%%
, VertPos%%
)) 'Fronts _PUTIMAGE (107 * (HorizPos%%
- 1) + 7, 107 * (VertPos%%
- 1) + 7), ObverseImg&
'Backs Pelmanism` = False
DoGrid` = False
DoMore` = False
DoGrid` = False
K$ = ""
HorizPos%% = XX%% + 1
VertPos%% = YY%% + 1
IF Choisi`
(HorizPos%%
, VertPos%%
) OR (FirstH%%
= HorizPos%%
AND FirstV%%
= VertPos%%
) THEN 'Do nothing
Motion`(HorizPos%%, VertPos%%, 1) = True 'Set this cell turning
Flipping` = True
FirstH%% = HorizPos%%
FirstV%% = VertPos%%
'CALL UseUpMouse
'Try Again?
ValidMouse` = False
LINE (0, 0)-(109, 69), , B
Highlight& = MakeHardware&(TempImg&)
ValidMouse` = False
IF XMouse%
> 195 AND XMouse%
< 295 AND YMouse%
> 275 AND YMouse%
< 335 THEN ValidMouse` = True
XHighLight% = 190
YHighLight% = 270
ValidMouse` = True
XHighLight% = 190
YHighLight% = 365
IF XMouse%
> 195 AND XMouse%
< 295 AND YMouse%
> 275 AND YMouse%
< 335 THEN 'Another Game DoMore` = False
DoMore` = False
Pelmanism` = False
DoMore` = False
Pelmanism` = False
DoMore` = False
K$ = ""
'Freeimages
FOR N%%
= 0 TO NoObjectsLess1%%
PRINT #1, BestScore%
(N%%
)
PRINT "Click on the mouse below with your normal button";
PRINT "Click (not double-click) to make this screen disappear";
CorrectButton` = False: ButtonNo%% = 1
'Assumes hardware has mouse buttons, value <=5
CorrectButton` = True
ButtonNo%% = 1
CorrectButton` = True
ButtonNo%% = 2
CorrectButton` = True
ButtonNo%% = 3
CorrectButton` = True
ButtonNo%% = 4
CorrectButton` = True
ButtonNo%% = 5
SHARED ButtonNo%%
, Skilled`
, Pelmanism`
, DoGrid`
, DoMore`
, Level%%
'Set Game Level
LINE (0, 0)-(69, 89), , B
Highlight& = MakeHardware&(TempImg&)
Skilled` = False
ValidMouse` = False
DoGrid` = True
DoMore` = True
ValidMouse` = False
Level%% = 2
ValidMouse` = True
Level%% = 1
ValidMouse` = True
Level%% = 0
ValidMouse` = True
Skilled` = True
Level%% = 0
Skilled` = True
Level%% = 1
Skilled` = True
Level%% = 2
Skilled` = True
Pelmanism` = False
DoGrid` = False
DoMore` = False
K$ = ""
'CALL UseUpMouse