BASIC Code wrote:
::DCS6
:"FFFF80018001800180018001800180018001800180018001800180018001FFFF
:"33182AA033282A282A18000002D806480A482648000000000000000000000000
:ClrHome
:8→A:4→B
:8→C:8→D
:1→H
:"WθX0→Str2
:"-!-¡→Str9
:Lbl 0
:prgmZMAP9
:Pause
:For(Y,1,8
:For(X,1,16
:[A](Y,X
:{9,1,9,3,4,5→L3
:Output(B,A,"π
:Lbl B
:While 1
:Repeat Ans
:getKey
:End
:Ans→K
:(K=24)+2(K=25)+3(K=26)+4(K=34→H
:Output(B,A,"
:A-(K=24 and [A](B,A-1)≠L3([A](B,A-1)+1))+(K=26 and [A](B,A+1)≠L3([A](B,A+1)+1→A
:B+(K=34 and [A](B+1,A)≠L3([A](B+1,A)+1))-(K=25 and [A](B-1,A)≠L3([A](B-1,A)+1→B
:Output(B,A,"π
:Goto Z
:A→I:B→J
:I-(H=1 and [A](B,A-1)2)+(H=3 and [A](B,A+1)2→I
:J-(H=2 and [A](B-1,A)2)+(H=4 and [A](B+1,A)2→J
:Lbl Z
:If A=1:Then
:15→A:D-1→D
:Goto 0:End
:If A=16:Then
:2→A:D+1→D
:Goto 0:End
:If B=1:Then
:7→B:C-1→C
:Goto 0:End
:If B=8:Then
:2→B:C+1→C
:Goto 0:End
:While 0:
:If 7.5=abs(.5(A-8.5)) or 3.5=abs(.5(B-4.5
:Goto 0
:If A=1 or A=16 or B=1 or B=8
:Then
:D-(A=1)+(A=16→D
:C-(B=1)+(B=8→C
:Ans→C
:A+15(A=1)-14(A=16→A
:B+7(B=1)-6(B=8→B
:End
:If Ans:Goto 0
:Lbl Y
:End:End
:End:End
Generated by SourceCoder, © 2005-2010 Cemetech
Would you mind saying what some of the testing code is for? You stated on IRC that some of it was code simply for testing purposes. I'll look through this, though I wouldn't count on it Razz I'm CADing Very Happy
_player1537 wrote:
Would you mind saying what some of the testing code is for? You stated on IRC that some of it was code simply for testing purposes. I'll look through this, though I wouldn't count on it Razz I'm CADing Very Happy


That was on the part that displayed the map, in the subprogram, not in this.

Code:
:If A=1:Then
:15→A:D-1→D
:Goto 0:End
:If A=16:Then
:2→A:D+1→D
:Goto 0:End
:If B=1:Then
:7→B:C-1→C
:Goto 0:End
:If B=8:Then
:2→B:C+1→C
:Goto 0:End

I could have sworn that we optimized this earlier in the topic, no?
_player1537 wrote:

Code:
:If A=1:Then
:15→A:D-1→D
:Goto 0:End
:If A=16:Then
:2→A:D+1→D
:Goto 0:End
:If B=1:Then
:7→B:C-1→C
:Goto 0:End
:If B=8:Then
:2→B:C+1→C
:Goto 0:End

I could have sworn that we optimized this earlier in the topic, no?

We did, but it didn't work with the code above it, so I just kept using that until I get something else working perfectly.

Code:

:A-(K=24 and [A](B,A-1)≠L3([A](B,A-1)+1))+(K=26 and [A](B,A+1)≠L3([A](B,A+1)+1→A
:B+(K=34 and [A](B+1,A)≠L3([A](B+1,A)+1))-(K=25 and [A](B-1,A)≠L3([A](B-1,A)+1→B

These too can be optimized other than what Kerm was mentioning.

When I make engines such as this, I like to have it use temporary coordinates that represent where it's trying to move, then do collision detection with those coordinates.
MufinMcFlufin wrote:

Code:

:A-(K=24 and [A](B,A-1)≠L3([A](B,A-1)+1))+(K=26 and [A](B,A+1)≠L3([A](B,A+1)+1→A
:B+(K=34 and [A](B+1,A)≠L3([A](B+1,A)+1))-(K=25 and [A](B-1,A)≠L3([A](B-1,A)+1→B

These too can be optimized other than what Kerm was mentioning.

When I make engines such as this, I like to have it use temporary coordinates that represent where it's trying to move, then do collision detection with those coordinates.

That is more of a pain in my opinion though, because those temp. coordinates have to change according to direction anyways.
Sonlen wrote:
MufinMcFlufin wrote:

Code:

:A-(K=24 and [A](B,A-1)≠L3([A](B,A-1)+1))+(K=26 and [A](B,A+1)≠L3([A](B,A+1)+1→A
:B+(K=34 and [A](B+1,A)≠L3([A](B+1,A)+1))-(K=25 and [A](B-1,A)≠L3([A](B-1,A)+1→B

These too can be optimized other than what Kerm was mentioning.

When I make engines such as this, I like to have it use temporary coordinates that represent where it's trying to move, then do collision detection with those coordinates.

That is more of a pain in my opinion though, because those temp. coordinates have to change according to direction anyways.


Code:

:A-(K=24)+(K=26→Y
:B-(K=34)+(K=25→Z
If [A](Z,Y)≠L3([A](Z,Y)+1)
Then
Y→A
Z→B
End

This ought to work
Ooh, very nice code Very Happy From the looks of it, it should work Smile I would have made it much more complicated :/ Though I have used this method before Smile
I see no reason to have


Code:
:Repeat Ans
:getKey
:End
:Ans→K
instead of
Code:
:Repeat Ans
:getKey→K
:End

Code:
:C+(B=1)-(B=8)→C
:D+(A=1)-(A=16)→D
:real(10,1,1
:"ZMAP"+sub("12345678",1+4int(C/4-4‾¹)+int(D/4-4‾¹),1
:real(10,0,1
:prgmXTEMP001
:real(10,1,1
:ClrHome
:{8,16→dim([A]
:length(Str1→W
:1→θ
:While θ≠W
:For(X,1,8
:For(Z,1,16
:[A](X,Z
:expr(sub(Str1,θ,1→V
:θ+1→θ
:V→[A](X,Z
:If Ans
:Output(X,Z,sub("WθXO",Ans,1
:End:End
:Return
:Pause

Can't figure out why this only works with UP and LEFT, this is the exact code that I am using.
Sonlen wrote:

Code:
:C+(B=1)-(B=8)->C
:D+(A=1)-(A=16)->D

Can't figure out why this only works with UP and LEFT, wait a minute and I will post the rest of the code since I have to look it up a couple pages back.
Yeah, it would help to see that in context. As-is I see no problems with it.

Edit: I see nothing in your code about getKey or modification of A and B. Can you move around down and right around a single screen?
KermMartian wrote:
Sonlen wrote:

Code:
:C+(B=1)-(B=8)->C
:D+(A=1)-(A=16)->D

Can't figure out why this only works with UP and LEFT, wait a minute and I will post the rest of the code since I have to look it up a couple pages back.
Yeah, it would help to see that in context. As-is I see no problems with it.

Edit: I see nothing in your code about getKey or modification of A and B. Can you move around down and right around a single screen?

That is in the Main engine, this is ZMAP, which is called when you hit the sides of the map.
I am working on an update of the main Engine as it is, and will post it soon.

Here is the Main Engine Code:
BASIC Code wrote:
::DCS6
:"FFFF80018001800180018001800180018001800180018001800180018001FFFF
:"33182AA033282A282A18000002D806480A482648000000000000000000000000
:ClrHome
:8→A:4→B
:8→C:8→D
:1→H
:"WθX0→Str2
:"-!-¡→Str9
:Lbl 0
:prgmZMAP9
:{9,1,9,3,4,5→LH
:Output(B,A,"π
:Lbl B
:While 1
:Repeat Ans
:getKey→K
:End
:(K=24)+2(K=25)+3(K=26)+4(K=34→H
:Output(B,A,"
:A-(K=24 and [A](B,A-1)≠LH([A](B,A-1)+1))+(K=26 and [A](B,A+1)≠LH([A](B,A+1)+1→A
:B+(K=34 and [A](B+1,A)≠LH([A](B+1,A)+1))-(K=25 and [A](B-1,A)≠LH([A](B-1,A)+1→B
:Output(B,A,"π
:A-(K=24)+(K=26)→X
:B-(K=25)+(K=34)→Z
:If [A](Z,X)≠LH([A](Z,X)+1
:Then:X→A:Z→B
:End
:If 7.5=abs(.5(A-8.5)) or 3.5=abs(.5(B-4.5
:A+15(A=1)-2(A=16→A
:B+7(B=1)-2(B=8→B
:Goto 0:End
Generated by SourceCoder, © 2005-2010 Cemetech
Sonlen wrote:
KermMartian wrote:
Sonlen wrote:

Code:
:C+(B=1)-(B=8)->C
:D+(A=1)-(A=16)->D

Can't figure out why this only works with UP and LEFT, wait a minute and I will post the rest of the code since I have to look it up a couple pages back.
Yeah, it would help to see that in context. As-is I see no problems with it.

Edit: I see nothing in your code about getKey or modification of A and B. Can you move around down and right around a single screen?

That is in the Main engine, this is ZMAP, which is called when you hit the sides of the map.
I am working on an update of the main Engine as it is, and will post it soon.

Here is the Main Engine Code:
BASIC Code wrote:
::DCS6
:"FFFF80018001800180018001800180018001800180018001800180018001FFFF
:"33182AA033282A282A18000002D806480A482648000000000000000000000000
:ClrHome
:8→A:4→B
:8→C:8→D
:1→H
:"WθX0→Str2
:"-!-¡→Str9
:Lbl 0
:prgmZMAP9
:{9,1,9,3,4,5→LH
:Output(B,A,"π
:Lbl B
:While 1
:Repeat Ans
:getKey→K
:End
SadK=24)+2(K=25)+3(K=26)+4(K=34→H
:Output(B,A,"
:A-(K=24 and [A](B,A-1)≠LH([A](B,A-1)+1))+(K=26 and [A](B,A+1)≠LH([A](B,A+1)+1→A
:B+(K=34 and [A](B+1,A)≠LH([A](B+1,A)+1))-(K=25 and [A](B-1,A)≠LH([A](B-1,A)+1→B
:Output(B,A,"π
:A-(K=24)+(K=26)→X
:B-(K=25)+(K=34)→Z
:If [A](Z,X)≠LH([A](Z,X)+1
:Then:X→A:Z→B
:End
:If 7.5=abs(.5(A-8.5)) or 3.5=abs(.5(B-4.5
:A+15(A=1)-2(A=16→A
:B+7(B=1)-2(B=8→B
:Goto 0:End
Generated by SourceCoder, © 2005-2010 Cemetech

Hey, I'm working on optimizing this code right now, but I have a few errands I have to go run, so I'll be back later tonight. For now, here's a suggestion; instead of having your While 1, an infinite loop, store whether or not your current position is on the border (A=1 or A=16 or B=1 or B=16->J) and then have the engine's loop terminate when that variable equals one, and then from there have it load a new map, and restart the engine. If done correctly, then you won't have to worry about memory leakage.

Experiment with that idea while I'm gone, and I'll work on what I have (I wrote your code done, then made a version of ZMAP9 that will work for my purposes, so I can play around with it as well)

Later!
This is wrong and not at all what I suggested:


Code:
:If 7.5=abs(.5(A-8.5)) or 3.5=abs(.5(B-4.5
:A+15(A=1)-2(A=16→A
:B+7(B=1)-2(B=8→B
:Goto 0:End
That will only conditionally execute the A line; the B line and the Goto will always happen.
Up and left don't work because that would read positions 0 and -3 in the "ZMAP" substring.

[EDIT]

Wait... it only works with up and left? *brain hurt*
KermMartian wrote:
This is wrong and not at all what I suggested:


Code:
:If 7.5=abs(.5(A-8.5)) or 3.5=abs(.5(B-4.5
:A+15(A=1)-2(A=16→A
:B+7(B=1)-2(B=8→B
:Goto 0:End
That will only conditionally execute the A line; the B line and the Goto will always happen.


Did I miss something with that, I thought that it will only use the Goto when either A or B meets the conditions.
Not the way you have it written. Razz And kindly address what Weregoose said, perhaps?
KermMartian wrote:
Not the way you have it written. Razz And kindly address what Weregoose said, perhaps?

I am sorry weregoose, I didn't see that, I was trying to post before I had to go install some hard drives in a room. It will go UP and LEFT for the map change, if I go down or right, it just reloads the same map you are currently on.
Sonlen wrote:
KermMartian wrote:
Not the way you have it written. Razz And kindly address what Weregoose said, perhaps?

I am sorry weregoose, I didn't see that, I was trying to post before I had to go install some hard drives in a room. It will go UP and LEFT for the map change, if I go down or right, it just reloads the same map you are currently on.
Ah, but you can move the player's sprite down and right along the current single screen? That would imply that the A=1 and B=1 cases aren't correctly being checked to decrement C or D.
  
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
» Goto page Previous  1, 2, 3 ... 12, 13, 14, 15, 16  Next
» View previous topic :: View next topic  
Page 13 of 16
» 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