1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

Pixel rotation not sub pixels(Fixed)

Discussion in 'Programming' started by DullShrimp129, Nov 7, 2019 at 10:24 PM.

  1. DullShrimp129

    DullShrimp129 Member

    Feb 18, 2018
    I am currently attempting to rotate a sprite using code to be pixel perfect. I initially simply rotated in an image editor and made its image_index = VPos(image_angle)/-7.2(50 images, 360 degrees, 360/7.2=50).
    The issue with this is the amount of weapons in the game is to much and it slows GM having individual weapons each having an entire rotated set. I tried messing around with possible using the round() function but it image_angle never rounds correctly to a whole pixel, so how could you rotate an image without sub pixels?
    (I understand GM actually scales out the amount of pixels to allow for smooth movement but i would like to have the room size remain the same due to the room editor.)
  2. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Apr 13, 2016
    You need to set the application surface to be same size as the room. So, for example, if you have a room that is 240x135, and then use a viewport (window size) that is 960x540, the app surface will be at this size so you'll get sub-pixels drawn. Use the function surface_resize() after setting up the initial view ports to set the app surface to the correct size, which for our example would be 240x135, and GMS2 wlll then draw things correctly, scaling up the app surface to fit the game window.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice