• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

Sprites & Y coord

Wingnut

Well-known member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
1,414
Here's how to draw a sprite inside the game itself.

I bumped into a problem. The coordinates for the sprite seems out of place. You need to add 1 to the y coordinate (not x only y).
Is this a rounding error, some kind of bug? I include screenshots so you can see the invidiual pixels. One with Y = 0 (where you cannot see the top pixel line), and one with Y=1 where you can just see the perfect sprite.


Code:
Import mojo2

Function Main()
    New MyApp
End

Class MyApp Extends App
   
    ' Define sprite
    Field sprite:Image            ' sprite is what we use to refer to when we want to draw the sprite *TO* the main canvas.
    Field spritecanvas:Canvas ' spritecanvas is what we use to refer to when we want to draw *TO* the sprite.
   
    Field def:String
    Field canvas : Canvas

    Method OnCreate()
        canvas = New Canvas
        SetUpdateRate 0      
        ' Create Sprite
        sprite=New Image(16,16,0,0,0) ' Align to upper left corner and no AA.
        spritecanvas=New Canvas(sprite)
        createSprite(spritecanvas)
    End

    Method OnRender()
        canvas.Clear
        canvas.DrawImage sprite,0,0 ' HERE IS THE PROBLEM! Why is 1 needed for y to see the whole sprite and not 0?
        canvas.Flush
    End
   
    ' CREATE A SPRITE! HAVE FUN!
   
    Method createSprite(cp:Canvas)
   
        cp.Clear 0,0,0,0
       
        ' CYAN
        cp.SetColor 0,1,1
               def = " *   ****   *   " ' Put something distinct to see the top part of the sprite.
         def = def + "   ********     "
         def = def + "  **********    "
         def = def + " ************   "
         def = def + " ************   "
         def = def + " ************   "
         def = def + "**************  "
         def = def + "**************  "
         def = def + "**************  "
         def = def + "**************  "
         def = def + "**************  "
         def = def + "**************  "
        def = def + "**************  "
        def = def + "**************  "
        def = def + "** ***  *** **  "
        def = def + "*   **  **   *  "        
         Local tempx:Int = 0, tempy:Int = 0
         For Local temp:Int = 1 To Len(def)
             If Mid(def,temp,1) = "*" Then cp.DrawRect tempx,tempy,1,1
             tempx = tempx + 1 ; If tempx >= 16 Then tempx=tempx-16 ; tempy = tempy + 1
         Next
       
         ' BLACK
        cp.SetColor 0,0,0
        cp.DrawOval 1,4,4,5
        cp.DrawOval 8,4,4,5
        cp.DrawLine 4,12,9,12
           
        ' WHITE
        cp.SetColor 1,1,1
        cp.DrawOval 1,4,2,2
        cp.DrawOval 8,4,2,2
               
        cp.Flush
    End
   
    Function Len:Int(s:String)
        Return s.Length
    End
   
    Function Mid:String(s:String,p:Int,n:Int)
        p=p-1 ; Return s[(p)..(p+n)]
    End

End
 

Attachments

  • y=0.jpg
    y=0.jpg
    2.2 MB · Views: 67
  • y=1.jpg
    y=1.jpg
    1.8 MB · Views: 77
Last edited:
It seems to happen on a basic level.
You can get it down to this.

Code:
Import mojo2

Function Main()
    New MyApp
End

Class MyApp Extends App
    
    Field canvas : Canvas

    Method OnCreate()
        canvas = New Canvas
    End

    Method OnRender()
        canvas.Clear
                
        ' No dot in left upper corner, you have to add 1 to y for it to show
        canvas.SetColor 1,1,1
        canvas.DrawRect 0,0,1,1
        
    canvas.Flush
    End
 

End
 
It happens on macos HTML5, Desktop, And compiling to Android on macOS.
On Linux and Windows (both Desktop and HTML..canättry Android from there but they would probably be fine too) are allright.

I must have done this test before on a mac and must have worked so this must be something new. I use Big Sur still as I don't like update too quick, I always wait for it to mature. But the computer was online and I'm sure it has updated something without asking me. It seems that macOS might have a new 1-pixel-y-difference thing going on. This is what I conclude from this anyways.

The fact that Android also gets the same problem when now compiled from Big Sur makes me confused. It can't possisbly be a bad macOS driver or other OS mechanism in that case?
 
Last edited:
Trying to help deducing what it could be.. all devices that does not have this bug is coming from the last binary, kinda old
v2021-05-16. These seem to work. Older ones seem to work as well. On the mac with the problem I've compiled from Github.
Maybe something happened on the way from there?


If you use a fresh Github compiled version please try on any platform and report please.

I've doublechecked all the progess and all the things that have been fixed since then, and nothing can be directly tied to this kind of behaviour. What could be the source?!

Just want to make clear that the pixel is somwhat here it's just rounded upwards like crazy but you get a weak version of it
if you overdo the size of the window. But this is not what it should be like.
 
Last edited:
Have now overwritten every existing file except the bin folder with the newest github set of files and Linux still does not have this problem.
I have not recompiled anything. So maybe I should update macos soon and see what happens.

EDIT
So readingthe web makes me think that BigSur changed the AA. You can't shut it off.
But what about newest Android, it behaves the same way. Did both OSes change AA system these last few months? That's my current guess actaully. I'm perplexed about Android changing at the same time. It doesn't feel very believe but the pixels on the top on both systems now are really fainted.
 
Last edited:
Here is what the top picture looks like when you compile on macOS and zoom the webpage, it starts to be seen.
You can see the same on Android 12. So ya.. bummer for someone who does not like AA if it's true?

macos zoomed HTML5.png
 
Again, multiple posts to show a fucking Problem you have. PLEASE, if you think there is a bug, post a simple piece of code in one post. Not a book. This way I tend to ignore your stuff because most of the time you figure it out yourself anyway.
 
I'll focus my energy somewhere else I can take a hint. Not a problem.
 
Sorry if I offended you. But you seem not to get my post. Please go on as you were.
 
Back
Top Bottom