:(direction)pressed? Returning to MZX, simple problem
#1
Posted 23 January 2015 - 09:49 PM
end
:uppressed
*Hello
end
Just to test it. And it doesn't seem to be registering. Am I forgetting something or doing it wrong? I must be, makes no sense.
Also, it's very doubtful after more than a decade, but if anyone has the alpha version or art folder from my game Ariandora which I had sent out for testing I would greatly appreciate a copy of it. Otherwise I'm going to have to start over! Ah well (Ariandora topic from a long time ago)
#2
Posted 23 January 2015 - 10:02 PM
: "loop" wait for 1 if uppressed then "hello" goto "loop" : "hello" * "Hello" goto "loop"
There are also a few built-in counters that you can use to detect keypresses. They use a predefined set of numbers that map to different keys on the keyboard.
: "loop" wait for 1 if "KEY_PRESSED" = 273 then "up" if "KEY_CODE" = 72 then "up" if "KEY72" = 1 then "up" goto "loop" : "up" * "Hello" goto "loop"
Hope that helps!
xx̊y (OST) - HELLQUEST (OST) - Zeux I: Labyrinth of Zeux (OST) (DOS OST)
w/ Lancer-X and/or asgromo: Pandora's Gate - Thanatos Insignia - no True(n) - For Elise OST
MegaZeux: Online Help File - Keycode Guide - Joystick Guide - Official GIT Repository
#3
Posted 23 January 2015 - 10:12 PM
#4
Posted 24 January 2015 - 09:05 PM
if player char '=)' then "label"
But when I try variations of it, it gets put to, if at "player char"... & so on. Am I mistaken in thinking you can use the player character as a conditional? & thanks in advance, I'll give credit to those that helped me with this (should be..) simple engine.
#5
Posted 24 January 2015 - 11:03 PM

<Malwyn> Yes, yes. Don't worry I'd rather masturbate with broken glass than ask you for help again. :(
#6
Posted 25 January 2015 - 03:34 AM
Please feel free to continue to ask for help here, I just mentioned that because you will find a lot more info than you could think to ask us. I actually read through the entire help file at one point just to fill myself in on all of MegaZeux's many changes over the years. The help file by Terryn is a fantastic resource for information, just sayin'
"Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you’re a mile away and you have their shoes."
-Jack Handey
#7
Posted 25 January 2015 - 05:25 PM
Oneiros, on 24 January 2015 - 01:05 PM, said:
if player char '=)' then "label"
But when I try variations of it, it gets put to, if at "player char"... & so on. Am I mistaken in thinking you can use the player character as a conditional? & thanks in advance, I'll give credit to those that helped me with this (should be..) simple engine.
Worth noting that while that conditional doesn't exist, you can effectively get that result by using the bchX,Y counters:
if "bch&playerx&,&playery&" = [The Char's Number] then "label"
This post has been edited by ThDPro: 25 January 2015 - 05:25 PM
Better Than Nothing - DOMINATION - Commander Keen: Heroes Lost - Welkin - A Confectioner's Recipe - random ThDPro music stuff
<Risu21121> if you're not going to make a good game, you might as well make a blatantly racist one.
<Kuddy> Testicles.
"Where are my folder?" - KKairos
#8
Posted 25 January 2015 - 05:49 PM
set maxhealth "maxhealth"
Locking the player is also very easy to manipulate through Robotic. Rather than using lockplayer and unlockplayer, simply increase and decrease a "lock" counter in all your peasantry board robots, and have your global king robot do the actual locking and unlocking. This way you can "stack" the ability to lock the player. For example, you have some sort of electric stunning code that locks the player for ten cycles then unlocks them. Let's say you also have a cutscene that (of course) locks the player, and you want to use this electric stun effect in the cutscene. The electric code could accidentally unlock the player early, before the cutscene's done. Instead, if controlled through a counter, lock will go up to 1, then 2 while the player's "stunned", then back down to 1 until the cutscene's done.
While you're fiddling around in the global robot (which is a good place to put things like this), also make a counter that simply increases by one every cycle. Very handy to have!
(EDIT: It's 2015 and I'm still calling MZX cutscenes "cinemas")
This post has been edited by CJA: 25 January 2015 - 05:54 PM
#9
Posted 03 February 2015 - 02:45 AM
Would anyone be willing to take a look at my 8-directional walking engine? I almost have it complete but there are a couple issues I can't work out. The coding is sloppy cause I'm not a professional programmer & am self-taught, I'm sure there are some shortcuts or easier ways of doing what I'm trying to do. If anyone is willing to help, post your email & I'll give you credit if you can fix it or simplify it. The problem comes when the players presses right to face northeast then presses up to go northeast without taking any other action. Instead of putting the player northeast, it puts the player to the north unless the player was already in movement. Also there are some glitchy aspects where turning a certain direction while having been turning opposite will produce undesired effects, which I can't figure out. Actually I'll just post the two robots that are running & see if anyone can help or simplify this where it's easier to predict & manage. I have it where you can walk in circles pretty neatly but there are just a few nagging problems before I could package it together as something for Robotic beginners & finally release something for once other than helping other people on projects 10+ years ago
It uses two robots. One checks if pressing up, to move the player:
: "upcheck"
if uppressed then "walk"
wait for 3
goto "upcheck"
end
: "walk"
if "dir" = 1 then "walkn"
if "dir" = 2 then "walknw"
if "dir" = 3 then "walkw"
if "dir" = 4 then "walksw"
if "dir" = 5 then "walks"
if "dir" = 6 then "walkse"
if "dir" = 7 then "walke"
if "dir" = 8 then "walkne"
end
: "walkn"
if at NORTH of player is c?? Solid "solid" then "upcheck"
move player to NORTH
goto "upcheck"
end
: "walknw"
if at WEST of player is c?? Solid "solid" then "upcheck"
if at NORTH of player is c?? Solid "solid" then "upcheck"
rel to player
put player at -1 -1
goto "upcheck"
end
: "walkw"
if at WEST of player is c?? Solid "solid" then "upcheck"
move player to WEST
goto "upcheck"
end
: "walksw"
if at WEST of player is c?? Solid "solid" then "upcheck"
if at SOUTH of player is c?? Solid "solid" then "upcheck"
rel to player
put player at -1 1
goto "upcheck"
end
: "walks"
if at SOUTH of player is c?? Solid "solid" then "upcheck"
move player to SOUTH
goto "upcheck"
end
: "walkse"
if at EAST of player is c?? Solid "solid" then "upcheck"
if at SOUTH of player is c?? Solid "solid" then "upcheck"
rel to player
put player at 1 1
goto "upcheck"
end
: "walke"
if at EAST of player is c?? Solid "solid" then "upcheck"
move player to EAST
goto "upcheck"
end
: "walkne"
if at EAST of player is c?? Solid "solid" then "upcheck"
if at NORTH of player is c?? Solid "solid" then "upcheck"
rel to player
put player at 1 -1
goto "upcheck"
end
The other checks if pressing left or right to change the player's heading/facing:
: "keycheck"
if leftpressed then "left"
if rightpressed then "right"
wait for 3
goto "keycheck"
end
: "left"
if "dir" = 1 then "northwest"
if "dir" = 2 then "west"
if "dir" = 3 then "southwest"
if "dir" = 4 then "south"
if "dir" = 5 then "southeast"
if "dir" = 6 then "east"
if "dir" = 7 then "northeast"
if "dir" = 8 then "north"
end
: "right"
if "dir2" = 1 then "northeast2"
if "dir2" = 2 then "east2"
if "dir2" = 3 then "southeast2"
if "dir2" = 4 then "south2"
if "dir2" = 5 then "southwest2"
if "dir2" = 6 then "west2"
if "dir2" = 7 then "northwest2"
if "dir2" = 8 then "north2"
end
: "northwest"
player char is ''
set "dir" to 2
set "dir2" to 8
wait for 3
goto "keycheck"
end
: "west"
player char is ''
set "dir" to 3
set "dir2" to 7
wait for 3
goto "keycheck"
end
: "southwest"
player char is '\t'
set "dir" to 4
set "dir2" to 6
wait for 3
goto "keycheck"
end
: "south"
player char is ''
set "dir" to 5
set "dir2" to 5
wait for 3
goto "keycheck"
end
: "southeast"
player char is ''
set "dir" to 6
set "dir2" to 4
wait for 3
goto "keycheck"
end
: "east"
player char is ''
set "dir" to 7
set "dir2" to 3
wait for 3
goto "keycheck"
end
: "northeast"
player char is ''
set "dir" to 8
set "dir2" to 2
wait for 3
goto "keycheck"
end
: "north"
player char is ''
set "dir" to 1
set "dir2" to 1
wait for 3
goto "keycheck"
end
: "northeast2"
player char is ''
set "dir1" to 8
set "dir2" to 2
wait for 3
goto "keycheck"
end
: "east2"
player char is ''
set "dir" to 7
set "dir2" to 3
wait for 3
goto "keycheck"
end
: "southeast2"
player char is ''
set "dir" to 6
set "dir2" to 4
wait for 3
goto "keycheck"
end
: "south2"
player char is ''
set "dir" to 5
set "dir2" to 5
wait for 3
goto "keycheck"
end
: "southwest2"
player char is '\t'
set "dir" to 4
set "dir2" to 6
wait for 3
goto "keycheck"
end
: "west2"
player char is ''
set "dir" to 3
set "dir2" to 7
wait for 3
goto "keycheck"
end
: "northwest2"
player char is ''
set "dir" to 2
set "dir2" to 8
wait for 3
goto "keycheck"
end
: "north2"
player char is ''
set "dir" to 1
set "dir2" to 1
wait for 3
goto "keycheck"
end
If it's easier just to e-mail you the game file to work with it, let me know your e-mail. I'll give full credit for the assistance if I ever release it or make something more of it, which I plan to
#10
Posted 03 February 2015 - 04:25 AM
Oneiros, on 02 February 2015 - 06:45 PM, said:
Would anyone be willing to take a look at my 8-directional walking engine?
Hi Oneiros, I gave it a look and only noticed a few things. I implemented your code into a test game and noticed that you must set "dir" and "dir2" each to 1 (or some valid number, 1-8) for the keycheck program to begin working. If you do not, then those counters are set to 0 and the program will fail. no biggie, you just use
set "dir" to 1 set "dir2" to 1
at the beginning of the program and that's fixed, right?
the other thing I noticed is that on line 85 of the keycheck program you use the command
set "dir1" to 1
instead of
set "dir" to 1
and this is the reason for the undesired/unexpected performance.
Other than that it seems to work well as intended. I could re-write it and refine it for you but I don't want to do that. I think you are doing well and the fastest way for you to learn is to do it yourself. So, Keep going!
P.S. I tried to write this exact program in ZZT-OOP many years ago but could not figure out how to do it. HA!
"Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you’re a mile away and you have their shoes."
-Jack Handey
#11
Posted 03 February 2015 - 05:20 AM
Graham, on 02 February 2015 - 08:25 PM, said:
Actually, that might not be true, I think you are doing very well, and it may be very beneficial to have someone show you a quicker way to do what you are doing. I learned a lot of techniques from opening other peoples games and checking out their code to see how it worked.
If I get some time, I'll see if I can duplicate your program in a different fashion. Or, maybe somebody faster than me will get to it first.
P.S. If you run into anymore trouble, don't hesitate to ask.
"Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you’re a mile away and you have their shoes."
-Jack Handey
#12
Posted 03 February 2015 - 08:03 PM
#13
Posted 03 February 2015 - 09:27 PM
Graham, on 03 February 2015 - 03:20 PM, said:
very true. my learning of robotic was heavily accelerated by the 2001/2002 doz game "torn creation"; first, just from seeing that game and realising that everything in it was possible to do in mzx. then, gradually pulling apart the robots and learning how everything was done, seeing certain practices and realising how they were useful and a better way of doing things than the ways i had previously intuited. i had dissected plenty of mzx games before that (that's how i learned mzx, really) but none that were anything like torn creation in their use of robotic.

<Malwyn> Yes, yes. Don't worry I'd rather masturbate with broken glass than ask you for help again. :(
#14
Posted 03 February 2015 - 11:20 PM
In other words, it's very helpful to look at other peoples' code
xx̊y (OST) - HELLQUEST (OST) - Zeux I: Labyrinth of Zeux (OST) (DOS OST)
w/ Lancer-X and/or asgromo: Pandora's Gate - Thanatos Insignia - no True(n) - For Elise OST
MegaZeux: Online Help File - Keycode Guide - Joystick Guide - Official GIT Repository
#15
Posted 08 February 2015 - 04:30 AM
Oneiros, on 02 February 2015 - 06:45 PM, said:
Hey again Oneiros, so there are some simple things you can do to clean up the program and simplify it. When creating an engine, you want it to be as simple as it can be. I would combine the two robots into one program. that way, there is only one robot a designer would have to add to his board. to do this, combine the two loops at the top of each robot into one loop. You want to check whether up is pressed every cycle, otherwise it would seem unresponsive, but you only want left and right checked every second or third cycle, otherwise the turning circle would be too tight. you can accomplish this with a loop within your loop like so:
: "top" loop start cycle 1 if uppressed then "#&dir&" loop for 2 if leftpressed then "#dec" if rightpressed then "#inc" goto "top"
This method also takes advantage of subroutines (the labels that are preceded by a '#'). They are like labels but when you are finished, they return you to the line after they were called and continue to run the program as normal. Read about them in the help file if that doesn't make sense. basically, you would use the command goto "#return" to return to the line after the subroutine was called, instead of goto "upcheck" and goto "keycheck".
Now you should think about doing away with a counter for each direction, left & right, and just go with one counter that they both share. so use "dir" for both left and right, and have left decrease the counter (until 1, resetting it to 8), and right increase the counter (until 8, resetting it to 1).
Next up, you can do away with this whole section
: "walk" if "dir" = 1 then "walkn" if "dir" = 2 then "walknw" if "dir" = 3 then "walkw" if "dir" = 4 then "walksw" if "dir" = 5 then "walks" if "dir" = 6 then "walkse" if "dir" = 7 then "walke" if "dir" = 8 then "walkne"
by utilizing the counter you already have set to represent the directions. This is where
if uppressed then "#&dir&"
comes in. See those '&' symbols? when you read that line, you should read it like "If uppressed, then go to the VALUE of the counter 'dir'."
and instead of having your labels be "walkn", "walknw", "walkw", etc. they can be "1", "2", "3" and the program will go directly to those labels from the 'if uppressed' command.
Programming is really a lot of fun, so I hope you stick with it and continue to improve your skills. I am self taught as well, I've just been doing it longer than you. You can definitely get to where I'm at with time, and even better, like some of these people in here =^)
BTW, I don't want to discourage you from releasing this engine, I definitely think you should. But have you considered a more modern approach to an 8 direction movement engine? What you are designing is called "tank controls" and it kind of fell out of fashion in the 90's. It certainly could still have it's uses, but maybe you could design and release an 8 way engine that uses all four direction buttons and release it in the same game. sort of a two-fer?
Anyway I'm happy to assist you so if you have more questions feel free to ask them. there is even room for more refinement if you want. there are other methods of moving the player around and checking for collision that may make the program even slicker.
"Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you’re a mile away and you have their shoes."
-Jack Handey
#16
Posted 27 February 2015 - 04:29 AM
This post has been edited by Old-Sckool: 27 February 2015 - 04:29 AM
<phthalocyanine> they make experiences.
<Nadir> demos, more like
<Nadir> a glimpse into what could have been if mzx wasn't such a bore to work with
<Nadir> actually, i'm being unfair
<Nadir> i would have made mzx games if it was capable of running on more than 20 computers worldwide in 1998
<Nadir> >:D
<%Alice> functor
<%nooodl> i hear C++ has a thing called functors and they're completely different from Haskell functors...
<rorirover> the result is the most horrid thing in C++, it's basically black magic and it transforms any code you're writing into some eldritch monstrosity
#17
Posted 01 March 2015 - 03:07 AM
Old-Sckool, on 26 February 2015 - 08:29 PM, said:
Good idea. Thanks for pointing that out.
"Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you’re a mile away and you have their shoes."
-Jack Handey