Part 22. Tutorial Stack 14. Bug Hunt
NOTE: Old SHMUP Tutorial Stacks removed. Will attach latest and greatest stacks to my first and last posts of thread.
I'll put all the changes up front. The blow by blow is below and second post
- Tutorial Stack 14
1. changed PlayerMove handling of the X mouse position, 20 pixel change = change in ship direction
2. Warps now ping pong the player, flipping their direction on exit
3. Fixed OptionsApplied to work on Title Card without throwing a bug
4. Copied "Viewer" button to Title card
5. Extended the mountain length by 50 units per point to guarantee scroll space in the group
6. Fixed UpdateStackSize to run all the updates instead of skipping over them in some cases
7. Removed storing EffectStates in UpdateEffectStates
8. Added StoreEffectStates to InitGame
9. Fixed OptionsApplied to hide/show the group "Backgroup" when bUseBackMountains is set false in Title screen before it's made
10. Removed a bunch of 'unlock screens' PlayGame handles most of them
11. Hid OptionsGroup and PauseMenuGroup in via Play Card script
12. Moved PauseMenu out of LoadingScreen and into PauseGame
13. Added on RawkeyDown to try to capture the EscapeKey better but it's still sporadic
14. Added ExitTitleCard before it called TitleGlow when using OptionsGroup and/or PauseMenuGroup
15. Added DistToScreen to create the bullet speeds, replacing the random number generator
16. Removed Excessive lines of LERP code in enemy bullets, replace with simple vector calculation
17. Added Midpoint, Endpoint, and RotatePoints functions to stack script
I think that's it for the basic game ya? Lets playtest a few hours and see.
And just two seconds to find a bug.
Code: Select all
if bUseBackMountains is false is true then
hide group "Backgroup"
else
show group "BackGroup"
end if
Ain't no group "BackGroup" on the
Title card.
If options are set in the "
Title" card we need to allow screen size, full screen, music volume, and then exit
OptionsApplied if we are not on card "
Play"
So right after we set the music volume variable
currentMusicVolume we'll exit the handler
Ah have to move the
UpdateStackSIze up the message path where it can be triggered as well
Code: Select all
send UpdateStackSIze to stack (The mainStack of this stack ) in 300 milliseconds
if the currentCard of this stack is "Title" then
TitleCardOpened
exit OptionsApplied
end if
Since we can set options at the "
Title" card we'll need to revist them in
InitGame to have the game match the choise we made, right before we set the timeOfInit so we effect all the graphics that made have been created and give the player precious milliseconds of game time before the difficulity level increases.
Back to the bug hunt.
Okayaaa, Because the WarpPoints are set initially along the points of the mountain and the points of the mountain are incremented in steps from 2 to 150 , there can be a condition where we can't scroll the group far enough to reach the warp. Let's try making the mountains bigger.
Code: Select all
put 50+random(50)+random(100)into nextX
Okay that seems to work fine, and the forerground mountains become more lumpy hillside which is pleasant.
Now why is the
viewer button floating in the middle of the screen? TYPO!
set the bottom of button "Viewer" to item 2
of of HW ---oops
Nope, not just that.
Because
UpDateStackSize is being called on the Title screen then
lastRect is being set to the rect of the window before "viewer" card is drawn and then
Code: Select all
put lastRect into lRect
if cRect is not lRect then
Fails to run all the various
Play card updates
So last track the card with a new variable
lastCard and only modify it in
UpdateStackSize
Fixed. With some extra adjustments so viewer card is as wide as the window and centered.
UpDateStackSize needed to be called again in InitGame so changes made on the "
Title" card were applied on the "
Play" card.
I supposed I could have added a bunch of "Of card "Play" to ever statement...
bleh.
Code: Select all
--// if the stack size has changed adjust various game elements to center screen
on UpDateStackSize
put the rect of stack (the mainStack of this stack) into cRect
put lastRect into lRect
put the currentCard of this stack into curCard
lock screen
if cRect is not lRect or lastCard is not curCard then
put stackDepth() into HW
put CenterScreen() into CSxy
set the width of button "Viewer" to item 2 of HW
set the loc of button "Viewer" to CSxy
set the width of button "Viewer" to item 1 of HW
set the left of button "Viewer" to 0
set the bottom of button "Viewer" to item 2 of HW
if the currentCard of this stack is "Play" then
ResetForegroundGroup
if bUseBackMountains is true then ResetBackgroundGroup
set the loc of graphic "player" to CSxy
set the loc of graphic "sMultBox" to CSxy
set the bottom of group "Developer" to item 2 of of HW
set the right of group "DevControlButtonGroup" to item 1 of HW
set the layer of group "DevControlButtonGroup" to top
--// fix the warps
WarpsToScreenHeight
end if
put cRect into lastRect
put curCard into lastCard
end if
end UpDateStackSize
Oh I was afraid of this. The effects aren't being stored or are being overwritten empty.... lets see now.
Okay All saving of effect states via a call to
StoreEffectStates is handled at
InitGame
UpdateEffectStates is only works with prestored values and doesn't alter those.
Code: Select all
on UpdateEffectStates
put "outerGlow,innerShadow,colorOverlay,innerGlow,dropShadow" into theEffects
put the number of graphics of this stack into NUC
if bUseEffects is false then
repeat with i = 1 to NUC
repeat for each item e in theEffects
do "set the" && e && "of graphic i to false"
end repeat
end repeat
end if
if bUseEffects is true then
repeat with i = 1 to NUC
put the short name of graphic i into tObject
put the EffectStates of graphic i into stateList
if number of lines of statesList > 0 then
set itemDel to "="
repeat for each line SL in stateList
do "set the" && item 1 of SL && "of graphic i to"&& item 2 of SL
end repeat
end if
end repeat
end if
end UpdateEffectStates
OptionsApplied was checking that we had entered PlayGame and set "inProgress" to true in order to show or hide the background mountains. That was to ensure we'd actually created the mountains before trying to manipulate their visibility.
But it caused the mountains to be shown even if they were turned off on the Title screen options. This should fix things
Code: Select all
if bUseBackMountains is false and exists (group "Backgroup") then
hide group "Backgroup"
else
show group "BackGroup"
end if
Hrmmm, removed a bunch of 'unlock screens' that were floating around and let
PlayGame manage the unlocking of screens to reduce a bunch of split second flashes of things that should not be seen...and then
OptionsGroup was always visible when
Play card started, probably because I hit escape key to go back to the
Title card.
Added this to the card script
OpenCard to fix that
Code: Select all
if exists (group "OptionsGroup") then hide group "OptionsGroup"
if exists (group "PauseMenuGroup") then hide group "PauseMenuGroup"
Moved the call to
PauseMenu out of loadingScreen and into
PauseGame where it belongs.
Added on
RawKeyDown to check for the
EscapeKey because I had a hard time capturing key input when the stack was full screen sized.
Seems to be working, but then
Title card threw a fit because I wast trying to view the keyinput so I copied
Viewer button to
Title card.
Mashing
EscapeKey the
Title card created a ...lets call it a Train of calls to
TitleCardIdle which caused the throbbing game title effects to become a crazy flashing. Added this before
TitleGlow was called and
TitleCardIdle was sent a message to send again in
TitleCardidle
Code: Select all
if visible of group "OptionsGroup" is true or visible of group "PauseMenuGroup" is true then exit TitleCardIdle
I was looking at a way of getting consistant bulletspeed. The random number I was throwing at it was giving me some crazy slow bullets.
I think I found a good technique.
once the bullet has the delta value to taget we pass that to
DistToScreen
like so
Code: Select all
put DistToScreen(dx,dy,item 1 of playerXY,item 2 of playerXY) into distXY
DistToScreen finds how how far the the target is from the screen edge...in the direction that its traveling according to the delta
Code: Select all
function DistToScreen deltax,delty,originx,originy
if deltax < 0 then
put originx into distX
else
put originX- item 1 of screenDepth() into distX
end if
if delta <0 then
put originy into distY
else
put originY - item 2 of screenDepth() into distY
end if
return distX,distY
end DistToScreen
In the bullet we divided each result by a 100
Code: Select all
put (item 1 of distXY)/100 into vx
put (item 2 of distXY)/100 into vy
And now we got some murder bullets, it adds a bit if inaccuracy shots though.
They might be too fast, I dunno, I racked up 17770 points in game, but I made it.
Turns out we don't need this big pile of script in the bullets
Code: Select all
-// plot the trajectory to target as a series of x,y coordinates
repeat with i = 0 to 1 step 0.01
put item 1 of enemyXY +(item 1 of playerXY - item 1 of enemyXY) *i into newX
put item 2 of enemyXY +(item 2 of playerXY - item 2 of enemyXY) *i into newY
put newX & comma & newY & cr after pathToTarget
end repeat
filter pathToTarget without empty
--// use the first and last line of the point list to determine the x,y delta
put line 1 of pathToTarget into axy
put line -1 of pathToTarget into bxy
put deltaVal(item 1 of axy, item 1 of bxy)/100 into dx
put deltaVal(item 2 of axy, item 2 of bxy)/100 into dy
Just
Code: Select all
put deltaVal(item 1 of enemyXY, item 1 of playerXY)/100 into dx
put deltaVal(item 2 of enemyXY, item 2 of playerXY)/100 into dy
I'm having trouble getting the escape key to respond without dying or exitng the stack first.
It's sporadic and troublesome.