61
SCI Syntax Help / Re: SCI0: Title screen menu
« on: April 03, 2023, 12:14:59 AM »
Here's my script for recreating KQ1SCI's title screen for my KQ2SCI project:
Code: [Select]
;;; Sierra Script 1.0 - (do not remove this comment)
;
; King's Quest II SCI Remake
; By Brandon Blume
(script# TITLESCREEN_SCRIPT)
(include sci.sh)
(include game.sh)
(include keys.sh)
(use main)
(use game)
(use menubar)
(use obj)
(use cycle)
(use user)
(use controls)
(use feature)
(public
TitleScreen 0
)
(local
title1 = 0
title2 = 0
sIntro = 1
sBegin = 0
sCred = 0
sCont = 0
sMenuStart = 0
bootingup = TRUE
keyheld = FALSE
indicator = {}
)
(instance TitleScreen of Rm
(properties
picture 95;scriptNumber
)
(method (init)
; Set up the title screen
(= gDefaultPalette 1)
(ProgramControl)
(= gProgramControl TRUE)
(gGame setSpeed: 4)
(SL disable:)
(SetCursor gLoadingCursor (HaveMouse))
(TheMenuBar hide:)
(super init:)
(self setScript: RoomScript)
(gEgo init: hide:)
(theRomance init: hide:)
(theThrone init: hide: )
)
)
; (send gTheMusic:prevSignal(0)stop()number(1)loop(0)play())
(instance RoomScript of Script
(properties)
(method (changeState newState)
(= state newState)
(switch state
(0 (= cycles 20)
(SetCursor gLoadingCursor (HaveMouse))
)
(1
(= cycles 80)
(= bootingup FALSE)
(DrawPic scriptNumber dpOPEN_CENTEREDGE dpCLEAR gDefaultPalette)
(theRomance show:)
(theThrone show:)
(theSpark1 init: setCycle: Fwd)
(theSpark2 init: setCycle: Fwd)
(theSpark3 init: setCycle: Fwd)
(theSpark4 init: setCycle: Fwd)
(theSpark5 init: setCycle: Fwd)
(theSpark6 init: setCycle: Fwd)
(theSpark7 init: setCycle: Fwd)
(theSpark8 init: setCycle: Fwd)
(gTheMusic prevSignal: 0 stop: number: 1 loop: 0 play:)
(SetCursor gLoadingCursor 0)
(= title1
(Display
{SCI Alpha 0.1}
dsCOORD 0 170
dsALIGN alCENTER
dsWIDTH 320
dsCOLOUR clWHITE
dsBACKGROUND clTRANSPARENT
dsFONT 4
dsSAVEPIXELS
)
)
(= title2
(Display
{By: Brandon Blume}
dsFONT 4
dsCOORD 0 180
dsWIDTH 320
dsALIGN alCENTER
dsCOLOUR clWHITE
dsBACKGROUND clTRANSPARENT
dsSAVEPIXELS
)
)
)
(2
(= cycles 15)
(theRomance hide:)
(theThrone hide:)
(Display {} dsRESTOREPIXELS title1)
(Display {} dsRESTOREPIXELS title2)
)
(3
(if gDefaultPalette
(= gDefaultPalette 0)
)
(gGame setCursor: gNormalCursor (HaveMouse))
(= sMenuStart 1)
(theRomance dispose:)
(theThrone dispose:)
(Display {} dsRESTOREPIXELS title1)
(Display {} dsRESTOREPIXELS title2)
(buttonIntro init: loop: 1 setScript: pressIntro)
(buttonBegin init: loop: 2 setScript: pressBegin)
(buttonCred init: loop: 3 setScript: pressCred)
(buttonCont init: loop: 4 setScript: pressCont)
(cond
(sIntro (buttonSelect init: loop: 5 posn: 58 146))
(sBegin (buttonSelect init: loop: 5 posn: 161 146))
(sCred (buttonSelect init: loop: 5 posn: 58 165))
(sCont (buttonSelect init: loop: 5 posn: 161 165))
)
)
)
)
(method (handleEvent pEvent)
(super handleEvent: pEvent)
(if (== (pEvent type?) evKEYBOARD)
(if bootingup
(switch (pEvent message:)
(KEY_w
(= gDefaultPalette 0)
)
(KEY_W
(= gDefaultPalette 0)
)
(KEY_b
(= gDefaultPalette 2)
)
(KEY_B
(= gDefaultPalette 2)
)
(KEY_p
(= gDefaultPalette 3)
)
(KEY_P
(= gDefaultPalette 3)
)
)
else
(cond
((== (pEvent message:) KEY_RETURN)
(if sMenuStart
(cond
(sBegin (gTheMusic fade:) (gRoom newRoom: INITROOMS_SCRIPT))
(sCont (gGame restore:))
(sIntro
(= gIntro 1)
(gTheMusic fade:)
(gRoom newRoom: INTRO_SCRIPT)
)
(sCred
(= gCred 1)
(gTheMusic fade:)
(gRoom newRoom: INTROCREDITS_SCRIPT)
)
)
else
(RoomScript changeState: 3)
)
)
(sMenuStart
(Print
{Use the arrow keys then enter or mouse to select option.}
)
)
)
)
)
(if (== (pEvent type?) evJOYSTICK)
(if sMenuStart
(if (== (pEvent message:) 1) (selectorCheckUp)) ; UP
)
)
(if (== (pEvent type?) evJOYSTICK)
(if sMenuStart
(if (== (pEvent message:) 5) (selectorCheckDown)) ; Down
)
)
(if (== (pEvent type?) evJOYSTICK)
(if sMenuStart
(if (== (pEvent message:) 7) (selectorCheckLeft)) ; Left
)
)
(if (== (pEvent type?) evJOYSTICK)
(if sMenuStart
(if (== (pEvent message:) 3) (selectorCheckRight)) ; Right
)
)
(if (== (pEvent type?) evMOUSEBUTTON)
(if sMenuStart
(cond
(
(and
(> (pEvent x?) (buttonBegin nsLeft?))
(< (pEvent x?) (buttonBegin nsRight?))
(> (pEvent y?) (buttonBegin nsTop?))
(< (pEvent y?) (buttonBegin nsBottom?))
)
(if sBegin
(selectorZero)
(= sBegin 1)
(gTheMusic fade:)
(gRoom newRoom: INITROOMS_SCRIPT)
else
(pressBegin changeState: 2)
)
)
(
(and
(> (pEvent x?) (buttonCont nsLeft?))
(< (pEvent x?) (buttonCont nsRight?))
(> (pEvent y?) (buttonCont nsTop?))
(< (pEvent y?) (buttonCont nsBottom?))
)
(if sCont
(selectorZero)
(= sCont 1)
(gGame restore:)
else
(pressCont changeState: 2)
)
)
(
(and
(> (pEvent x?) (buttonCred nsLeft?))
(< (pEvent x?) (buttonCred nsRight?))
(> (pEvent y?) (buttonCred nsTop?))
(< (pEvent y?) (buttonCred nsBottom?))
)
(if sCred
(selectorZero)
(= gCred 1)
(gTheMusic fade:)
(gRoom newRoom: INTROCREDITS_SCRIPT)
else
(pressCred changeState: 2)
)
)
(
(and
(> (pEvent x?) (buttonIntro nsLeft?))
(< (pEvent x?) (buttonIntro nsRight?))
(> (pEvent y?) (buttonIntro nsTop?))
(< (pEvent y?) (buttonIntro nsBottom?))
)
(if sIntro
(selectorZero)
(= gIntro 1)
(gTheMusic fade:)
(gRoom newRoom: INTRO_SCRIPT)
else
(pressIntro changeState: 2)
)
)
(else
(Print
{Use the arrow keys then enter or mouse to select option.}
)
)
)
else
(RoomScript changeState: 3)
)
)
)
)
; Menu Selector Procedures
; Menu select UP
(procedure (selectorCheckUp)
(cond
(sBegin (selectorZero) (= sCred 1) (buttonSelect posn: 58 165))
(sCont (selectorZero) (= sBegin 1) (buttonSelect posn: 161 146))
(sCred (selectorZero) (= sIntro 1) (buttonSelect posn: 58 146))
(sIntro (selectorZero) (= sCont 1) (buttonSelect posn: 161 165))
)
)
; Menu select DOWN
(procedure (selectorCheckDown)
(cond
(sBegin (selectorZero) (= sCont 1) (buttonSelect posn: 161 165))
(sCont (selectorZero) (= sIntro 1) (buttonSelect posn: 58 146))
(sCred (selectorZero) (= sBegin 1) (buttonSelect posn: 161 146))
(sIntro (selectorZero) (= sCred 1) (buttonSelect posn: 58 165))
)
)
; Menu select LEFT
(procedure (selectorCheckLeft)
(cond
(sBegin (selectorZero) (= sIntro 1) (buttonSelect posn: 58 146))
(sCont (selectorZero) (= sCred 1) (buttonSelect posn: 58 165))
(sCred (selectorZero) (= sBegin 1) (buttonSelect posn: 161 146))
(sIntro (selectorZero) (= sCont 1) (buttonSelect posn: 161 165))
)
)
; Menu select RIGHT
(procedure (selectorCheckRight)
(cond
(sBegin (selectorZero) (= sCred 1) (buttonSelect posn: 58 165))
(sCont (selectorZero) (= sIntro 1) (buttonSelect posn: 58 146))
(sCred (selectorZero) (= sCont 1) (buttonSelect posn: 161 165))
(sIntro (selectorZero) (= sBegin 1) (buttonSelect posn: 161 146))
)
)
; Reset all menu buttons (for use when enabling a buttons variable)
(procedure (selectorZero)
(= sBegin 0)
(= sCont 0)
(= sCred 0)
(= sIntro 0)
)
; Mouse click on new button instances
; when selector is not currently on them
; Mouse click on Begin Game button
(instance pressBegin of Script
(properties)
(method (changeState newState)
(= state newState)
(switch state
(2
(= cycles 1)
(selectorZero)
(= sBegin 1)
(buttonSelect posn: 161 146)
)
(3
(gTheMusic fade:)
(gRoom newRoom: INITROOMS_SCRIPT)
)
)
)
)
; Mouse click on Introduction button
(instance pressIntro of Script
(properties)
(method (changeState newState)
(= state newState)
(switch state
(2
(= cycles 1)
(selectorZero)
(= sIntro 1)
(buttonSelect posn: 58 146)
)
(3
(gTheMusic fade:)
(gRoom newRoom: INTRO_SCRIPT)
)
)
)
)
; Mouse click on Credits button
(instance pressCred of Script
(properties)
(method (changeState newState)
(= state newState)
(switch state
(2
(= cycles 1)
(selectorZero)
(= sCred 1)
(buttonSelect posn: 58 165)
)
(3
(gTheMusic fade:)
(gRoom newRoom: INTROCREDITS_SCRIPT)
)
)
)
)
; Mouse click on Continue Game button
(instance pressCont of Script
(properties)
(method (changeState newState)
(= state newState)
(switch state
(2
(= cycles 3)
(selectorZero)
(= sCont 1)
(buttonSelect posn: 161 165)
)
(3 (gGame restore:))
)
)
)
; Forward then backward "Shimmer" animation
(instance shimmerScript of Script
(properties)
(method (changeState newState)
(= state newState)
(switch state
(1
(theSpark1 setCycle: End shimmerScript)
)
(2
(theSpark1 setCycle: Beg shimmerScript)
)
(3
(shimmerScript changeState: 1)
)
)
)
)
; make it all loop around forever!
; Prop Instances
(instance theRomance of Prop
(properties
x 86
y 166
view 913
cel 0
)
)
(instance theThrone of Prop
(properties
x 236
y 162
view 913
cel 1
)
)
(instance theSpark1 of Prop
(properties
; x 61 //KQ1
; y 27 //KQ1
x 67 ; KQ4
y 26 ; KQ4
view 950
cycleSpeed 2
)
)
(instance theSpark2 of Prop
(properties
x 97 ; Both
y 59 ; Both
view 950
cycleSpeed 3
cel 2
)
)
(instance theSpark3 of Prop
(properties
; x 130 //KQ1
; y 21 //KQ1
x 142 ; KQ4
y 20 ; KQ4
view 950
cycleSpeed 2
cel 4
)
)
(instance theSpark4 of Prop
(properties
; x 182 //KQ1
; y 21 //KQ1
x 187 ; KQ4
y 28 ; KQ4
view 950
cycleSpeed 1
)
)
(instance theSpark5 of Prop
(properties
; x 208 //KQ1
; y 54 //KQ1
x 213 ; KQ4
y 62 ; KQ4
view 950
cycleSpeed 7
cel 1
)
)
(instance theSpark6 of Prop
(properties
; x 264 //KQ1
; y 32 //KQ1
x 268 ; KQ4
y 38 ; KQ4
view 950
cycleSpeed 5
)
)
(instance theSpark7 of Prop
(properties
x 143
y 89
view 950
cycleSpeed 6
cel 3
)
)
(instance theSpark8 of Prop
(properties
x 174
y 117
view 950
cycleSpeed 4
)
)
(instance buttonIntro of Prop
(properties
x 58
y 146
view 950
)
)
(instance buttonBegin of Prop
(properties
x 161
y 146
view 950
)
)
(instance buttonCred of Prop
(properties
x 58
y 165
view 950
)
)
(instance buttonCont of Prop
(properties
x 161
y 165
view 950
)
)
(instance buttonSelect of Prop
(properties
; x 58
; y 146
view 950
)
)