You're going to have to use a lot of variables. Perhaps reuse a few.

Are you going to account for accuracy and speed (duration until next attack perhaps?), as well as anything else?
comicIDIOT wrote:
You're going to have to use a lot of variables. Perhaps reuse a few.

Are you going to account for accuracy and speed (duration until next attack perhaps?), as well as anything else?


Not sure right now, it will depend on how slow it gets when everything is implemented.

Also Kerm, your code seems to have a flaw, it won't move to the same row or column as the player, so I changed it from > to >= and it will move to the same row/column, but I can't find a way to check if it is on the player and stop the movement so it isn't on you. Plus I tried to do what I did with the player, storing the values to a temp var and storing it to the enemies X,Y won't work, for some reason it messes the values up and keeps trying to get off of the screen and give a dim error for the enemies Output position. :/
I can easily modify my code to allow it into the same row or column as the player but not both. Smile Silly me for not thinking of that case. Razz
KermMartian wrote:
I can easily modify my code to allow it into the same row or column as the player but not both. Smile Silly me for not thinking of that case. Razz


Thanks, I tried a couple different ways I could think of, but I couldn't get it to actually work, it would either not move the enemy at all (I think that was a collision check issue I made), not move it to the same row/column, or would move onto the player.
How about this? I've only posted the part of the code between the markers in my previous post that has to do with moving the enemy. I'm actually not 100% confident this will work, but it's worth a try...


Code:
:"V- ENEMY MOVE -V"
:If V=5 and 1<abs(T-Z)+abs(S-X
:Then
:round(rand->Q
:Output(S,T," ") //one space
:If not(Q
:S-abs(S-X)/(S-X->S
:If Q
:T-abs(T-Z)/(T-Z->T
:End
:"^- ENEMY MOVE -^"
KermMartian wrote:
How about this? I've only posted the part of the code between the markers in my previous post that has to do with moving the enemy. I'm actually not 100% confident this will work, but it's worth a try...


Code:
:"V- ENEMY MOVE -V"
:If V=5 and 1<abs(T-Z)+abs(S-X
:Then
:round(rand->Q
:Output(S,T," ") //one space
:If not(Q
:S-abs(S-X)/(S-X->S
:If Q
:T-abs(T-Z)/(T-Z->T
:End
:"^- ENEMY MOVE -^"


I will test that later, thanks.
Also is there a way to check if a key is being held down instead of (like what getKey does) only the arrow keys work in this manner.

What I am wanting to do is use XLib to invert a certain part of the screen only while a key is being held down, but getKey requires you to press the key again instead of just being let go and re-inverting what I want.

I hope that makes sense.
You could sort of fake it by storing both last-key-pressed and current-key-pressed. As long as they're equal and equal to the key you want, the key is held; as soon as they're unequal once, the key was released.
KermMartian wrote:
You could sort of fake it by storing both last-key-pressed and current-key-pressed. As long as they're equal and equal to the key you want, the key is held; as soon as they're unequal once, the key was released.


Such a simple solution I entirely overlooked. Shock Thanks for that. Very Happy
Any time, glad to help. I'm particularly interested to know if the code that I posted above to you works or not. I'd be somewhat surprised if it does indeed work, but I have a hunch that I might have gotten lucky with an idea I had.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 2 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement