suffer: they were meant to read the code!

The map is ripped-off from battle for Wesnoth.

https://www.wesnoth.org/
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
I was still able to add images with less than 10 postings so yeah.
so ur calling me 12.richmond62 wrote: ↑Fri Nov 29, 2019 2:49 pmThat was a half-finished thing of mine designed to make my 9-12 year old victims
suffer: there were meant to read the code!
The map is ripped-off from battle for Wesnoth.![]()
https://www.wesnoth.org/
but this doesn't match for the code in my game.richmond62 wrote: ↑Fri Nov 29, 2019 8:11 amSorry, I got distracted last night.
Code: Select all
on rawKeyDown RAWK put empty into fld "fKEE" switch RAWK case "32" put "SPACE" into fld "fKEE" break case "119" put "w" into fld "fKEE" break case "65362" put "UP" into fld "fKEE" break default pass rawKeyDown end switch end rawKeyDown
At 57 years old that took me a week of work!so ur calling me 12.
I tried but it just didn't work here's a screenshot. Another screenshot.richmond62 wrote: ↑Fri Nov 29, 2019 6:01 pmNo, it doesn't match the code in your game.
If I sorted your game out for you it would be my game.![]()
But with a bit of lateral thinking, you can use my code to help you with yours.![]()
Code: Select all
...
switch RAWK
case 32
## put "SPACE" into fld "fKEE"
## Do your thing here when user pressed -> SPACE
break
case 119
## put "w" into fld "fKEE"
## Samew here for -> w
break
case 65362
## put "Arrow key UP" into fld "fKEE"
## and here for -> ARROW KEY UP
break
default
pass rawKeyDown
...
I made my code like this and it finally worked!Klaus wrote: ↑Sat Nov 30, 2019 1:38 pmHi Starpat,
the message "rawkweydown" returns a NUMBER (the keycode of the pressed key) and not its "value"!
So take another look at Richmonds script and try again.
Hint: Really no need to QUOTE numbers!BestCode: Select all
... switch RAWK case 32 ## put "SPACE" into fld "fKEE" ## Do your thing here when user pressed -> SPACE break case 119 ## put "w" into fld "fKEE" ## Samew here for -> w break case 65362 ## put "Arrow key UP" into fld "fKEE" ## and here for -> ARROW KEY UP break default pass rawKeyDown ...
Klaus
P.S.
Your "rawkeyUP" handler will OVERWRITE ALL VALUES for birdDirection you have just set in "rawkeydown"!
Code: Select all
on keyDown theKey
if theKey is space then
put -1 into birdDirection
else
if theKey is "w" then
put -1 into birdDirection
end if
end if
end keyDown
on arrowKey AK
if AK is "up" then
put -1 into birdDirection
end if
end arrowKey
on rawKeyUp
put 1 into birdDirection
end rawKeyUp
Code: Select all
on rawKeyDown tKey
switch tKey
## SPACE, w and ARROW KEY UP do the same thing, so we can do this:
case 32
case 65362
case 119
put -1 into birdDirection
break
## ANY other pressed keys:
default
put 1 into birdDirection
break
end switch
end rawKeyDown
Not that I'd like to admit this in public, but Klaus has beenSee, much cleaner and even shorter!
Love you, honeybunny!richmond62 wrote: ↑Sat Nov 30, 2019 7:15 pmNot that I'd like to admit this in public, but Klaus has been something of a mentor to me for the last 20 years re LiveCode.