--> Total noob question --> -->

Author Topic: Total noob question  (Read 19938 times)

0 Members and 1 Guest are viewing this topic.

Offline matthias1992

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 408
  • Rating: +33/-5
    • View Profile
Total noob question
« on: July 14, 2010, 09:39:17 am »
Yesterday was my first hands on experience with Axe, and I love it! despite the compiled files being nearly 2x larger then the source it is incredibely fast! I do have one problem however, moving sprites. I used this code
Code: [Select]
.SPRITE
DiagnosticOff
10->X->Y
[FFFFFFFFFFFFFFFF->Pic0
Lbl DR
Pt-On(X,Y,Pic0)
Return
Repeat getKey(15)
If getKey(2)
X-1->X
sub(DR)
End
If getKey(3)
X+1->X
sub(DR)
End
End
now instead of moving one pixel left or right the sprite moves 8 pixels. How can I make this one pixel? Am I doing something wrong?

And on a slightly off topic note: I was trying to read The Complete guide to effective Axe by SirCwmp but after page 3 or so there are only blank pages (except the titles of the chapaters) can someone either verify this or upload a non-corrputed version (assuming it is not meant to have those blank spaces)

edit:just another question, how do I display sprites bigger then 8x8 at once? or do I have to make, say, a 32x32 sprite from four 8x8 sprites?
Thanks in advance.
« Last Edit: July 14, 2010, 09:55:49 am by matthias1992 »
MASM xxxxxxxxxx aborted | SADce ====:::::: 40% -Halted until further notice| XAOS =====::::: 50% -Units done| SKYBOX2D engine ========== 100% -Pre-alpha done. Need to  document it and extend |

~Those who dream by day are cognizant of much more than those who dream by night only. -Sir Edgar Allen Poe-

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: Total noob question
« Reply #1 on: July 14, 2010, 10:19:40 am »
One at a time. :P
AFAIK, SirCmpwn never actually released it. What you're probably talking about is just a bit he wrote up so we could give feedback on formatting.
As for larger sprites, you have two options. The first one is to use the Bitmap( command, which is a bit slower (being an OS call) and somewhat inflexible. Your other option is two draw multiple sprites, though, for 32*32, that would be 16 8*8 sprites.
Now to your main question.
First of all, the subroutine DR you have should be at the end of your code, because otherwise your program will right after drawing the sprite once. Also, you need to erase the sprite at its original location when you move it because the edges get left behind. Depending on what else you're doing, you could erase the whole screen, backup the entire screen to the backbuffer, or you might have some other option that I can't think of right now.
Also, that said, are you sure it's exactly 8 pixels? That shouldn't happen. If you haven't realized yet, the direct key commands (of the form getkey(9)) are much faster than just using getkey, and it's probably just moving very quickly.
(Note that some of my criticisms of your code may not be valid, as I'm unsure if what you posted is just an example)
Good luck in Axe! :)
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline Magic Banana

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 371
  • Rating: +77/-1
  • It's not an apple, it's a ... magic banana.
    • View Profile
Re: Total noob question
« Reply #2 on: July 14, 2010, 10:35:02 am »
Eh, just woke up, but let's see what we got here.

Yeah, calcdude basically covers it. I'm not seeing a DispGraph, so this program doesn't seem to be doing anything. If you don't want the sprite leaving a trail, then make sure you ClrDraw after using DispGraph. Both of those should be put after you've done all the drawing on the screen, so after sub(DR) is called. Oh, it's not really needed, but when closing a program, having ClrHome right before the program ends will clean up your screen when you exit out of it. Otherwise it seems ok. You don't really need to worry about optimizing right now so you should be fine. Just don't forget to make If statements for the Y coordinate. :)
I do sprites and stuff, so yeah.

Quote from: yunhua98
i'M NOT SURE WHAT A SWORD SKILL IS BUT HERE'S THE SWORD ANIMATION FROM THE TWO SPRITES ON PG 13

Offline jsj795

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1105
  • Rating: +84/-3
    • View Profile
Re: Total noob question
« Reply #3 on: July 14, 2010, 10:35:37 am »
In the subroutine DR, before Pt-On(, put ClrDraw for, well, clearing the screen, and after Pt-On(, put DispGraph so the sprites show after you've drawn them. And see if it works


Spoiler For funny life mathematics:
1. ROMANCE MATHEMATICS
Smart man + smart woman = romance
Smart man + dumb woman = affair
Dumb man + smart woman = marriage
Dumb man + dumb woman = pregnancy
2. OFFICE ARITHMETIC
Smart boss + smart employee = profit
Smart boss + dumb employee = production
Dumb boss + smart employee = promotion
Dumb boss + dumb employee = overtime
3. SHOPPING MATH
A man will pay $2 for a $1 item he needs.
A woman will pay $1 for a $2 item that she doesn't need.
4. GENERAL EQUATIONS & STATISTICS
A woman worries about the future until she gets a husband.
A man never worries about the future until he gets a wife.
A successful man is one who makes more money than his wife can spend.
A successful woman is one who can find such a man.
5. HAPPINESS
To be happy with a man, you must understand him a lot and love him a little.
To be happy with a woman, you must love her a lot and not try to understand her at all.
6. LONGEVITY
Married men live longer than single men do, but married men are a lot more willing to die.
7. PROPENSITY TO CHANGE
A woman marries a man expecting he will change, but he doesn't.
A man marries a woman expecting that she won't change, and she does.
8. DISCUSSION TECHNIQUE
A woman has the last word in any argument.
Anything a man says after that is the beginning of a new argument.

Girls = Time * Money (Girls are a combination of time and money)
Time = Money (Time is money)
Girls = Money squared (So, girls are money squared)
Money = sqrt(Evil) (Money is also the root of all evil)
Girls = sqrt(Evil) squared (So, girls are the root of all evil squared)
Girls = Evil (Thus, girls are evil)
*Girls=Evil credit goes to Compynerd255*

Offline Magic Banana

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 371
  • Rating: +77/-1
  • It's not an apple, it's a ... magic banana.
    • View Profile
Re: Total noob question
« Reply #4 on: July 14, 2010, 10:44:35 am »
Oh, one more thing, you should probably pull the sub(DR) out of the if loops and have it call the sub after all the button presses so that if there are multiple button presses (diagonal movement) it will only make the draw command once instead of multiple times, preventing any weird mishaps. Kind of like:
Code: [Select]
If getkey(1)
blah
End
If getkey(2)
blah
End
If getkey(3)
blah
End
If getkey(4)
blah
End
sub(DR)
DispGraph
ClrDraw

@jsj795
Hmm, clearing the screen right before drawing to it might not be the best thing, considering that he could draw something else to the buffer before sub(DR) is called. Usually it's best to have it right after you display the contents of the buffer to ensure that you got everything that was needed to be displayed to be uh, displayed.
« Last Edit: July 14, 2010, 10:45:01 am by Magic Banana »
I do sprites and stuff, so yeah.

Quote from: yunhua98
i'M NOT SURE WHAT A SWORD SKILL IS BUT HERE'S THE SWORD ANIMATION FROM THE TWO SPRITES ON PG 13

Offline matthias1992

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 408
  • Rating: +33/-5
    • View Profile
Re: Total noob question
« Reply #5 on: July 14, 2010, 10:55:06 am »
Ooh Yea i made some mistakes indeed so it should be:
Code: [Select]
.SPRITE
DiagnosticOff
10->X->Y
[FFFFFFFFFFFFFFFF->Pic0
[0000000000000000->Pic1
Repeat getKey(15)
If getKey(2)
X-1->X
sub(DR)
End
If getKey(3)
X+1->X
sub(DR)
End
End
Lbl DR
Pt-On(X-(getKey(3))+(getKey(2)),Y,Pic1) .I have not included Y movement yet for simplicity's sake.
Pt-On(X,Y,Pic0)
DispGraph .no return needed

I always try to avoid ClrDraw, maybe a bad habit in Axe but a good one on BASIC. I don't know with what logic the sprites are drawn so I am not sure if the Pic1 sprite will do what I want it to do, erase the previous position of Pic0...
I have no calc at hand so i am jsut doing this from memory and the commentary you made...
it should work now...

@magic banana
in your example code you dispGraph and then Clrdraw, shouldn't it be the other way around?
MASM xxxxxxxxxx aborted | SADce ====:::::: 40% -Halted until further notice| XAOS =====::::: 50% -Units done| SKYBOX2D engine ========== 100% -Pre-alpha done. Need to  document it and extend |

~Those who dream by day are cognizant of much more than those who dream by night only. -Sir Edgar Allen Poe-

Offline jsj795

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1105
  • Rating: +84/-3
    • View Profile
Re: Total noob question
« Reply #6 on: July 14, 2010, 10:56:36 am »
@magic banana oh... Thanks for the advice lol I'm so used to clearing screen before displaying :p I was also ninja'd by you before


Spoiler For funny life mathematics:
1. ROMANCE MATHEMATICS
Smart man + smart woman = romance
Smart man + dumb woman = affair
Dumb man + smart woman = marriage
Dumb man + dumb woman = pregnancy
2. OFFICE ARITHMETIC
Smart boss + smart employee = profit
Smart boss + dumb employee = production
Dumb boss + smart employee = promotion
Dumb boss + dumb employee = overtime
3. SHOPPING MATH
A man will pay $2 for a $1 item he needs.
A woman will pay $1 for a $2 item that she doesn't need.
4. GENERAL EQUATIONS & STATISTICS
A woman worries about the future until she gets a husband.
A man never worries about the future until he gets a wife.
A successful man is one who makes more money than his wife can spend.
A successful woman is one who can find such a man.
5. HAPPINESS
To be happy with a man, you must understand him a lot and love him a little.
To be happy with a woman, you must love her a lot and not try to understand her at all.
6. LONGEVITY
Married men live longer than single men do, but married men are a lot more willing to die.
7. PROPENSITY TO CHANGE
A woman marries a man expecting he will change, but he doesn't.
A man marries a woman expecting that she won't change, and she does.
8. DISCUSSION TECHNIQUE
A woman has the last word in any argument.
Anything a man says after that is the beginning of a new argument.

Girls = Time * Money (Girls are a combination of time and money)
Time = Money (Time is money)
Girls = Money squared (So, girls are money squared)
Money = sqrt(Evil) (Money is also the root of all evil)
Girls = sqrt(Evil) squared (So, girls are the root of all evil squared)
Girls = Evil (Thus, girls are evil)
*Girls=Evil credit goes to Compynerd255*

Offline LordConiupiter

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 339
  • Rating: +3/-0
  • Just one of the thousands of Axe-fans...
    • View Profile
Re: Total noob question
« Reply #7 on: July 14, 2010, 11:30:18 am »
@magic banana
in your example code you dispGraph and then Clrdraw, shouldn't it be the other way around?

Then you will draw a white screen all the time, and I guess that is not what you want :P
ClrDraw crears the buffer, and dispGraph writes the buffer to the screen, so when you want to draw something, most times you have to clear the buffer, draw everything you want on it, and then write it to the screen with the dispGraph command.
everytime that I was down, you would always come around, and get my feedback on the ground. (modified part from 'Seasons in the sun')

No matter how many errors are bothering you, always try to stay rel-Axe!

The HoMM project will be resumed as soon Axe 1.0.0 will be released!
Projects:
Code: [Select]
HoMM:   [==--------]    Project 'resumed': I'm suffering overwhelming new ideas being popped up in my dreams :P
tiDE:   [----------]    Explored and understood the main part of the code: just started writing a Tokenizer.



password of the week: uvanapererubupa (Any pronunciation is the right one ;) )   :D click me, and you'll be raided :D

Offline Magic Banana

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 371
  • Rating: +77/-1
  • It's not an apple, it's a ... magic banana.
    • View Profile
Re: Total noob question
« Reply #8 on: July 14, 2010, 12:36:33 pm »
I always try to avoid ClrDraw, maybe a bad habit in Axe but a good one on BASIC. I don't know with what logic the sprites are drawn so I am not sure if the Pic1 sprite will do what I want it to do, erase the previous position of Pic0...
I have no calc at hand so i am jsut doing this from memory and the commentary you made...
it should work now...

@magic banana
in your example code you dispGraph and then Clrdraw, shouldn't it be the other way around?
In Axe, DispGraph will display everything that has been drawn in the buffer onto the LCD and ClrDraw will clear the buffer, but NOT the screen. Axe is a little different than BASIC, so it will take some getting used to, but (almost) everything, unless specified, is drawn to the buffer while in BASIC, everything was drawn straight to the screen (or rather automatically updated to the screen whenever anything on the buffer was changed). In Axe, the LCD will only display what's on the buffer when you tell it to, so that is why you use DispGraph after you have drawn all of your sprites onto the buffer.

LordConiupiter is right about what you said. Deleting everything you draw on the buffer before it is displayed onto the screen = blank screen.

Also, in your sub you use Pt-On(X-(getKey(3))+(getKey(2)),Y,Pic1) do display a white block to which I am assuming to clear out the old space of where your sprite was before. There is no need for this, because your program isn't updating the screen until it gets to DispGraph, and even so, using that white block would erase anything behind your first sprite if there was anything. That is what ClrDraw is for. Unlike BASIC, everything get's drawn extremely fast because it's drawn to the buffer. Once you draw everything you need to, you simply call DispGraph once and BAM - everything is displayed on the screen all at once.

Before I get carried away about the differences between BASIC and Axe syntax, let me just revise your code a bit so you can see what I mean.
Code: [Select]
.SPRITE
DiagnosticOff
10->X->Y
[FFFFFFFFFFFFFFFF->Pic0
Repeat getKey(15)
X+getkey(3)-getkey(2)->X
Y+getkey(1)-getkey(4)->Y
sub(DR
DispGraph
ClrDraw
End
ClrHome

Lbl DR
Pt-On(X,Y,Pic0
« Last Edit: July 14, 2010, 12:41:34 pm by Magic Banana »
I do sprites and stuff, so yeah.

Quote from: yunhua98
i'M NOT SURE WHAT A SWORD SKILL IS BUT HERE'S THE SWORD ANIMATION FROM THE TWO SPRITES ON PG 13

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: Total noob question
« Reply #9 on: July 14, 2010, 08:45:44 pm »
Code: [Select]
.SPRITE                   . header
DiagnosticOff             . turn off indicator/done
10->X->Y                  . initialize sprite position
[3C7EFFFFFFFF7E3C->Pic0   . squares are for squares. therefore, a black circle is stored to pic0.
Repeat getKey(15)         . repeat until clear is pressed
X+getkey(3)-getkey(2)->X  . movement
Y+getkey(1)-getkey(4)->Y  . code
Pt-Change(X,Y,Pic0        . draw sprite to buffer
DispGraph                 . display what's on the buffer
Pt-Change(X,Y,Pic0        . draw same sprite to buffer. since it's pt-change, the sprite is erased on the buffer, leaving no
End                       . residue from movement.
ClrHome                   . clear the screen, move cursor to upper left corner of the screen.
ClrDraw                   . clear the buffer.

you can use a subroutine for pt-change() if those 10 bytes you save are really important to you.


Offline shmibs

  • しらす丼
  • Administrator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2132
  • Rating: +281/-3
  • try to be ok, ok?
    • View Profile
    • shmibbles.me
Re: Total noob question
« Reply #10 on: July 14, 2010, 09:12:19 pm »
a subroutine is nice when you use a routine more than once in your program but otherwise they should generally be avoided as they add size and make the program more difficult to read

also, nemo's ptchange method is useful if you want a background image without having to store it in the backbuffer and do swapping(freeing up more RAM for storage)

Offline matthias1992

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 408
  • Rating: +33/-5
    • View Profile
Re: Total noob question
« Reply #11 on: July 15, 2010, 06:22:03 am »
Code: [Select]
.SPRITE                   . header
DiagnosticOff             . turn off indicator/done
10->X->Y                  . initialize sprite position
[3C7EFFFFFFFF7E3C->Pic0   . squares are for squares. therefore, a black circle is stored to pic0.
Repeat getKey(15)         . repeat until clear is pressed
X+getkey(3)-getkey(2)->X  . movement
Y+getkey(1)-getkey(4)->Y  . code
Pt-Change(X,Y,Pic0        . draw sprite to buffer
DispGraph                 . display what's on the buffer
Pt-Change(X,Y,Pic0        . draw same sprite to buffer. since it's pt-change, the sprite is erased on the buffer, leaving no
End                       . residue from movement.
ClrHome                   . clear the screen, move cursor to upper left corner of the screen.
ClrDraw                   . clear the buffer.

you can use a subroutine for pt-change() if those 10 bytes you save are really important to you.

Thanks! but how comes it doesn't flicker? because every time Clear is not pressed it redraws the sprite...
MASM xxxxxxxxxx aborted | SADce ====:::::: 40% -Halted until further notice| XAOS =====::::: 50% -Units done| SKYBOX2D engine ========== 100% -Pre-alpha done. Need to  document it and extend |

~Those who dream by day are cognizant of much more than those who dream by night only. -Sir Edgar Allen Poe-

Offline LordConiupiter

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 339
  • Rating: +3/-0
  • Just one of the thousands of Axe-fans...
    • View Profile
Re: Total noob question
« Reply #12 on: July 15, 2010, 06:35:22 am »
that is because you don't clear the screen, but send directly the new data you want to it. The buffer flickers, but the screen just displays the bufferdata when it is sent to it.
everytime that I was down, you would always come around, and get my feedback on the ground. (modified part from 'Seasons in the sun')

No matter how many errors are bothering you, always try to stay rel-Axe!

The HoMM project will be resumed as soon Axe 1.0.0 will be released!
Projects:
Code: [Select]
HoMM:   [==--------]    Project 'resumed': I'm suffering overwhelming new ideas being popped up in my dreams :P
tiDE:   [----------]    Explored and understood the main part of the code: just started writing a Tokenizer.



password of the week: uvanapererubupa (Any pronunciation is the right one ;) )   :D click me, and you'll be raided :D

Offline matthias1992

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 408
  • Rating: +33/-5
    • View Profile
Re: Total noob question
« Reply #13 on: July 15, 2010, 06:57:17 am »
but doesn't that eventually cause memory fatigue?
MASM xxxxxxxxxx aborted | SADce ====:::::: 40% -Halted until further notice| XAOS =====::::: 50% -Units done| SKYBOX2D engine ========== 100% -Pre-alpha done. Need to  document it and extend |

~Those who dream by day are cognizant of much more than those who dream by night only. -Sir Edgar Allen Poe-

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: Total noob question
« Reply #14 on: July 15, 2010, 07:03:30 am »
The only time the screen changes is when you use "DispGraph".  The buffer itself is not the screen, its just a place in memory like a program or a variable.  Since the majority of commands draw things to this buffer location instead of the screen nothing actually happens to the LCD screen at all.  It just stays the way it is (no flickering).  The only time the display physically changes is when you use the DispGraph command which looks at the buffer and copies whatever's there to the screen.  It copies the data so fast in fact, that it appears the entire screen was updated instantly.  Once the screen has been updated with the DispGraph command, it will stay that way until the next DispGraph command so you are free to do whatever you want to the buffer in the mean time including clearing it and redrawing all the sprites.
___Axe_Parser___
Today the calculator, tomorrow the world!

 

\n\t\t\t\t\t\t\t\t\t
<' + '/div>\n\t\t\t\t\t\t\t\t\t