Browse Source

Fix offsets with AddToValue, tweak slides

master
Macoy Madson 1 year ago
parent
commit
63ac2c03dc
  1. 14
      data/DrivingCodeWithData.cakedata
  2. 11
      data/PowerSystem.cakedata
  3. 13
      src/Presentation.cake

14
data/DrivingCodeWithData.cakedata

@ -37,9 +37,10 @@ for each iceStorm in iceStorms:
{
updateIceStorm(iceStorm);
}")
(slide-data :heading "We want" :body "slime sling
laser blast
(slide-data :heading "We want" :body "rock smash
magma ball
heat seeker
boomerang
...")
(slide-data :heading "We have a problem")
(slide-data :heading "Second pass: sharing code"
@ -303,14 +304,5 @@ is hard.
That doesn't mean it shouldn't be done, but does
mean it should be done carefully.")
(slide-data :heading "In conclusion"
:body "Doing this is not hard,
knowing when to do this, and to what extent,
is hard.
That doesn't mean it shouldn't be done, but does
mean it should be done carefully.
Using data to drive code is powerful.")
(slide-data :heading "Questions?"
:trigger "random-power-cycle"))

11
data/PowerSystem.cakedata

@ -72,6 +72,7 @@ SetValue velocityX 25"
IfGreaterThanOrEqual positionX enemyX
PlayEffect smoke-explosion smoke-explosion-idle
SetValue velocityX 0
AddToValue positionY -65
DamageEnemy
Expire
End
@ -104,7 +105,8 @@ End")
(power
:id "iceStorm"
:on-create "PlayEffect ice-explosion ice-explosion-flying
SetValue velocityX 10"
SetValue velocityX 10
AddToValue positionY -50"
:on-update
"IfGreaterThanOrEqual velocityX 2
IfGreaterThanOrEqual positionX enemyX
@ -133,13 +135,14 @@ SetValue velocityX 20"
IfGreaterThanOrEqual positionX enemyX
PlayEffect explosion explosion-fast
SetValue velocityX 0
AddToValue positionY -45
DamageEnemy
Expire
End
End
IfEquals user0 0
IfGreaterThanOrEqual lifetimeFrameCount 2
SetValue relativeSpawnY -35
SetValue relativeSpawnY -45
SpawnPower explosion
SetValue user0 1
End
@ -195,8 +198,8 @@ End")
:id "rocks"
:on-create "PlayEffect rocks rocks-fall
SetValue positionX enemyX
SetValue positionY 610
SetValue positionY 410
SetValue positionY enemyY
AddToValue positionY -210
Expire"
:on-update "IfGreaterThanOrEqual lifetimeFrameCount 6
DamageEnemy

13
src/Presentation.cake

@ -237,6 +237,7 @@
operation-type-spawn-power
operation-type-set-value
operation-type-add-to-value
operation-type-if-equals
operation-type-if-string-equals
@ -278,6 +279,9 @@
(array
operation-type-set-value
"SetValue" 2)
(array
operation-type-add-to-value
"AddToValue" 2)
(array
operation-type-if-equals
"IfEquals" 2)
@ -735,6 +739,15 @@
;; (preslog "Setting %s to %s\n" (path op > string-a) (path op > string-b))
(set (deref value-out) (deref set-value-to))
(preslog "Failed to set %s to %s (not bound)\n" (path op > string-a) (path op > string-b))))
((= (path op > type) operation-type-add-to-value)
(var value-out (* int) (resolve-value-from-name
context (path op > string-a)))
(var add-value (* int) (resolve-value-or-literal-from-string
context (path op > string-b)))
(if (and value-out add-value)
;; (preslog "Setting %s to %s\n" (path op > string-a) (path op > string-b))
(set (deref value-out) (+ (deref value-out) (deref add-value)))
(preslog "Failed to add to %s %s (not bound)\n" (path op > string-a) (path op > string-b))))
((= (path op > type) operation-type-if-equals)
(var value-a (* int) (resolve-value-or-literal-from-string
context (path op > string-a)))

Loading…
Cancel
Save