Author Topic: Noob Help  (Read 11449 times)

0 Members and 1 Guest are viewing this topic.

Offline LT21j

  • LV0 Newcomer (Next: 5)
  • Posts: 2
  • Rating: +0/-0
    • View Profile
Noob Help
« on: May 29, 2011, 12:19:20 am »
Hey I'm a new for using axe parser, so i don't know alot of tricks and syntex. But I have programed a fair amount to understand basic commands. Anyway the problem I am programing a side scroller and the way I want to program someone walking is by testing getkey in a main repeat loop. And if a getkey equals a certain number like 2, then I want to change what it outputs by changed the value of the string 1. So In the beginning I set string1 to a value, (the character facing to the right), and when someone hits the left arrow key I want the person to turn to the left. So I want change the value of string1 to and image of the person facing to the left. But apparently you can't do that because every time I try to compile the program I get ERR: duplicate. So is there any trick to doing this or am I going in the complete wrong direction? Any help is greatly appreciated! Thanks

In case you couldn't understand what I was trying to say, here is the code:

:.BLA<br />:<br />:ClrDraw<br />:<br />:[4E4E447C440C1222]→Str1<br />:<br />:0→A<br />:56→B<br />:Repeat getKey(15)<br />:If getKey(1) and (B≠56<br />:B+1→B:End<br />:If getKey(2) and (A≠0<br />:A-1→A:End<br />:If getKey(3) and (A≠87<br />:[3A3A121E12182422]→Str1<br />:A+1→A:End<br />:If getKey(4) and (B≠0<br />:B-2→B:End<br />:If B<56<br />:B+1→B:End<br />:ClrDraw<br />:Pt-On(A,B,Str1)<br />:DispGraph<br />:End<br />Generated by <a href="http://sc.cemetech.net">SourceCoder</a>, © 2005-2011 <a href="http://www.cemetech.net">Cemetech</a>
« Last Edit: May 30, 2011, 08:31:03 am by LT21j »

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Noob Help
« Reply #1 on: May 29, 2011, 12:22:33 am »
I'm not quite sure what you mean by that.  Can you type out your source code either by hand or with Source Coder so we can see exactly what you're doing, so we can help you?

By the way, welcome to the forums! :D
« Last Edit: May 29, 2011, 12:22:45 am by ztrumpet »

Offline JosJuice

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1344
  • Rating: +66/-14
    • View Profile
Re: Noob Help
« Reply #2 on: May 29, 2011, 01:55:56 am »
I'm not quite sure what you mean by that.  Can you type out your source code either by hand or with Source Coder so we can see exactly what you're doing, so we can help you?
I think he's trying to store a value to Str1 and then store another value to it later in the program.

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Noob Help
« Reply #3 on: May 29, 2011, 02:34:02 am »
The Str, Pic, and GDB tokens are NOT variables.  They are static pointers so they can only be assigned to once and keep their value forever.  If you do need to change the value, simply use a variable instead.  Anywhere you can use "Str1" you can also use "A" or any other variable.
« Last Edit: May 29, 2011, 02:34:13 am by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: Noob Help
« Reply #4 on: May 29, 2011, 10:48:46 pm »
In fact, it gets even worse: They're just placeholders. When The compiler does its second pass, what it's doing is going back through the program and putting in the location of all the different pieces of data you're using, which are added at the end of the program after the last C9 [ret], so that the program ends execution before it reaches a bunch of bytes that are not intended to be executed. This is not entirely accurate, however, as Axe apparently mixes code with data sometimes, and I'm not quite sure how that data doesn't get accidentally executed.
Read the documentation (it helps! Really!), keeping in mind that whenever "program memory" is mentioned, what is meant is that those bytes get added to the compiled program as-is, placed in a location code execution will never reach.
« Last Edit: May 29, 2011, 10:51:50 pm by Freyaday »
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Noob Help
« Reply #5 on: May 29, 2011, 11:47:42 pm »
This is not entirely accurate, however, as Axe apparently mixes code with data sometimes, and I'm not quite sure how that data doesn't get accidentally executed.
The only time code will mix with data is when Axe adds its own sub-routines, like with the DispGraph command.  Basically, then any data defined before the first DispGraph is placed before the DispGraph sub-routine in the code, and any data defined after the first DispGraph is after it.

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: Noob Help
« Reply #6 on: May 29, 2011, 11:53:05 pm »
This is not entirely accurate, however, as Axe apparently mixes code with data sometimes, and I'm not quite sure how that data doesn't get accidentally executed.
The only time code will mix with data is when Axe adds its own sub-routines, like with the DispGraph command.  Basically, then any data defined before the first DispGraph is placed before the DispGraph sub-routine in the code, and any data defined after the first DispGraph is after it.
Is this supposed to happen, or is it a big?
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Noob Help
« Reply #7 on: May 29, 2011, 11:56:19 pm »
This is not entirely accurate, however, as Axe apparently mixes code with data sometimes, and I'm not quite sure how that data doesn't get accidentally executed.
The only time code will mix with data is when Axe adds its own sub-routines, like with the DispGraph command.  Basically, then any data defined before the first DispGraph is placed before the DispGraph sub-routine in the code, and any data defined after the first DispGraph is after it.
Is this supposed to happen, or is it a big?
bug? ;)
Nope, it's supposed to happen.  Basically the DispGraph routine is big, say around 100 bytes or so.  Each time you referenced it, you'd use 100 bytes or so out of your executable.  However, if you make it its own sub-routine, then it would only be 100 bytes or so (plus 10 or so to call the routine) and then only 10 more bytes or so each subsequent time the routine is called.

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: Noob Help
« Reply #8 on: May 29, 2011, 11:59:27 pm »
No, the data-mixing thing
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Noob Help
« Reply #9 on: May 30, 2011, 12:34:23 am »
Data and code are the same, its all just bytes so it completely depends on how you look at it.  The same way the a single unsigned number can also represent a signed number, or an 8.8 fixed point number, or a pointer, or a character, or a 4x4 sprite, or a hexadecimal number, or an octal number, etc.  The only difference is how you use it.  So only bytes designated by "subroutines" get called and jumped to, and only bytes designated as "Data" read and write to their location in memory.  It doesn't matter that they're mixed because each built-in axe subroutine is self containing and can go anywhere in memory, just like how you can put your own subroutines anywhere in your Axe code.
« Last Edit: May 30, 2011, 12:36:17 am by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Noob Help
« Reply #10 on: May 30, 2011, 02:56:50 am »
Code: [Select]
.BLA

ClrDraw

[4E4E447C440C1222]→Pic1

0→A
56→B
Repeat getKey(15)

If getKey(1) and (B≠56)
B+1→B
End

If getKey(2) and (A≠0)
A-1→A
End

If getKey(3) and (A≠87)
[3A3A121E12182422]→Pic1
A+1→A
End

If getKey(4) and (B≠0)
B-2→B
End

If B<56
B+1→B
End

Pt-On(A,B,Pic1)
DispGraphClrDraw

End

I think this is fairly better, but haven't tested it yet.
« Last Edit: May 30, 2011, 02:57:11 am by Scout »

Offline LT21j

  • LV0 Newcomer (Next: 5)
  • Posts: 2
  • Rating: +0/-0
    • View Profile
Re: Noob Help
« Reply #11 on: June 01, 2011, 08:54:25 am »
It didn't work it gave me the same answer :(

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Noob Help
« Reply #12 on: June 01, 2011, 09:18:22 am »
It didn't work it gave me the same answer :(

DUPLICATE? Oh yeah sorry, here's a fixed code:

Code: [Select]
.BLA

ClrDraw

[4E4E447C440C1222]→Pic1

0→A
56→B
Repeat getKey(15)
Pic1→O

If getKey(1) and (B≠56)
B+1→B
End

If getKey(2) and (A≠0)
A-1→A
End

If getKey(3) and (A≠87)
[3A3A121E12182422]→O
A+1→A
End

If getKey(4) and (B≠0)
B-2→B
End

If B<56
B+1→B
End

Pt-On(A,B,O)
DispGraphClrDraw

End

Offline Compynerd255

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +53/-4
  • Betafreak Games
    • View Profile
    • Betafreak Games
Re: Noob Help
« Reply #13 on: June 01, 2011, 10:46:51 am »
Actually, the best thing to do to prevent using up so much data is actually to define all of the sprites (right, left, up, down, front, back, etc.) at the beginning of the program, in seperate Pic variables. Then, simply store the correct Pic value to one of your variables.

Even better, if you are simply using left and right flipped sprites, use the flipH() command, which takes a Pic pointer and returns a pointer to the flipped sprite. You can then use that value directly in the Sprite command.
« Last Edit: June 01, 2011, 10:47:12 am by Compynerd255 »
The Slime: On Hold, preparing to add dynamic tiles

Axe Eitrix: DONE

Betafreak Games: Fun filled games for XBox and PC. Check it out at http://www.betafreak.com



Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: Noob Help
« Reply #14 on: June 09, 2011, 08:18:33 am »
Another solution:
You take a DirectionVariable (let's use D).
You put your 2 sprites at the beginning.
The first one is pointed at Str1+0, The second one is pointed at Str1+8.
Then you guess what's next.
I made a spelling mistake in the word Right but it is on purpose.
If it doesn't work, blame me and give me a -1.
Of course, you have to replace "[FacingLeftSpriteInHex]" by the hex code of your FacingLeftSprite.

:.BLA
:ClrDraw
:[FacingLeftSpriteInHex]→Str1
:[FacingRiteSpriteInHex]
:0→D

:0→A
:56→B
:Repeat getKey(15)
:If getKey(1) and (B≠56
:B+1→B:End
:If getKey(2) and (A≠0
:0→D
:A-1→A:End
:If getKey(3) and (A≠87
:8→D
:A+1→A:End
:If getKey(4) and (B≠0
:B-2→B:End
:If B<56
:B+1→B:End
:ClrDraw
:Pt-On(A,B,Str1+D)
:DispGraph
:End
« Last Edit: June 09, 2011, 08:33:00 am by Hayleia »
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s