Rotating a Wheel (one sprite image)

Started by AndreasBlack, Thu 28/04/2022 08:21:13

Previous topic - Next topic

AndreasBlack

I've downloaded modules and just started crying, pretty much. I make zero sense out of them.

I have a file called Wheels.Png and i've put it in the game folder.

Now i've found in the manual this section, but i have no idea how to turn my own sprite in the manual example, just replacing the bmp with my file that i've placed in the folder does not do the trick. An object with the chosen sprite? a view? a character? What is it in this context "a sprite" , cause the autofill won't show my "sprite" file (Wheels.png).
I get a nullpoint error, most likely cause it does not recognise the sprite file.

From the manual:

DynamicSprite* sprite = DynamicSprite.CreateFromFile("Wheels.png");
sprite.Rotate(90);
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground();
surface.DrawImage(100, 100, sprite.Graphic);
surface.Release();
sprite.Delete();

Crimson Wizard

#1
Quote from: AndreasBlack on Thu 28/04/2022 08:21:13
I've downloaded modules and just started crying, pretty much. I make zero sense out of them.

Which modules, is this also related to sprite rotation?

In regards to the sprite rotation.

1. Don't use standalone image files unless absolutely necessary. The examples in the manual are often horrible.
Instead, import as a regular sprite instead and create dynamic sprite from its number.
Code: ags

DynamicSprite* sprite = DynamicSprite.CreateFromExistingSprite(WHEEL_SPRITE_NUMBER);


2. Don't draw on room's background, unless absolutely necessary. Drawing on room will require you to also repaint background itself whenever the sprite must change.
Instead create a room object and assign dynamic sprite to it:
Code: ags

oWheel.Graphic = sprite.Graphic;


3. Don't delete the sprite until the object is no longer needed, because object is using it to display itself. You need to make a room variable that stores your dynamic sprite for the whole duration. You may delete the sprite when player leaves the room.
Code: ags

// room script
DynamicSprite* wheelSprite;

function Room_BeforeFadeIn()
{
    wheelSprite = DynamicSprite.CreateFromExistingSprite(WHEEL_SPRITE_NUMBER);
    wheelSprite.Rotate(90);
    oWheel.Graphic = wheelSprite.Graphic;
}

function Room_OnLeave()
{
    wheelSprite = null; // this will also delete the sprite if that's the only variable that references it
}


4. Also, when you need to rotate the sprite again, recreate it instead of changing previous dynamic sprite. This is because each rotation will degrade the image quality. For good results create a new dynamic sprite from the same original slot, rotate it and assign to the same variable and then to the object again.

AndreasBlack

#2
Quote from: Crimson Wizard on Thu 28/04/2022 08:44:54


Which modules, is this also related to sprite rotation?

In regards to the sprite rotation.




Dynamic Sprite Rotation v0.1 from Khris, some older module, but he wrote something about "pixels not being messy", which caught my eye. I didn't get it to work, at all.

and the The direct 3D plugin by AJA, i think i've red somewhere that you should be able to rotate with it, i know it's only available for PC, and i have no plan to do a "multiplattform" release in the future, yet anyway, so i would have liked to try it out, and see what it can do. I mean ofc i could try and rotate the wheel in animation instead, but it's not gonna look pretty. It's none aliased pixelart after all and it's obvious to the eye in Thimbleweed Park forexample that it's a sprite that is rotated with some 3d (probably) trickery or such. I will try what you've wrote out of course, but it sounds like it's not what i'm looking for since the antialias that is most likely is going to happen will ruin the pixelart, Thanks for your reply as always!




Crimson Wizard

Quote from: AndreasBlack on Thu 28/04/2022 12:51:25
and the The direct 3D plugin by AJA, i think i've red somewhere that you should be able to rotate with it, i know it's only available for PC, and i have no plan to do a "multiplattform" release in the future, yet anyway, so i would have liked to try it out, and see what it can do. I mean ofc i could try and rotate the wheel in animation instead, but it's not gonna look pretty. It's none aliased pixelart after all and it's obvious to the eye in Thimbleweed Park forexample that it's a sprite that is rotated with some 3d (probably) trickery or such. I will try what you've wrote out of course, but it sounds like it's not what i'm looking for since the antialias that is most likely is going to happen will ruin the pixelart, Thanks for your reply as always!

This is true, rotating the sprites with dynamic sprites will always be pixelated. D3D plugin should indeed solve this problem.
We also have an experimental version of AGS which supports rotating objects in 3D, but it's a wip version that changes often, and not "official" yet, so idk if i should recommend it.

AndreasBlack

Quote from: Crimson Wizard on Thu 28/04/2022 13:06:32



This is true, rotating the sprites with dynamic sprites will always be pixelated. D3D plugin should indeed solve this problem.
We also have an experimental version of AGS which supports rotating objects in 3D, but it's a wip version that changes often, and not "official" yet, so idk if i should recommend it.




Well at least the vehicle is moving with "drive sound effect" panning and the programming is all done as far as that little puzzle goes, gradually increasing speed etc. Maybe i could improve it using tweens instead but i've just done Character.setwalkspeed solution. Maybe something for future AGS releases to take into account vehicle acceleration switching gears, etc. It's just an image flying over the screen lookin' a bit unfinished atm.  :-D
I guess i'll have to wait for it then, maybe i'll give it a go later, perhaps you guys could use some feedback from the "average user", who knows. (roll)


Crimson Wizard

#5
Quote from: AndreasBlack on Thu 28/04/2022 14:12:31
Maybe something for future AGS releases to take into account vehicle acceleration switching gears, etc. It's just an image flying over the screen lookin' a bit unfinished atm.  :-D
I guess i'll have to wait for it then, maybe i'll give it a go later, perhaps you guys could use some feedback from the "average user", who knows. (roll)

Well, you don't really need future AGS releases to implement acceleration or switching gears, this all may be done in script. You also don't need Character.setwalkspeed, you may always set x,y position yourself, and then implement velocity and acceleration as variables that you change in script.

AndreasBlack

#6
Quote from: Crimson Wizard on Thu 28/04/2022 14:18:04Well, you don't really need future AGS releases to implement acceleration or switching gears, this all may be done in script. You also don't need Character.setwalkspeed, you may always set x,y position yourself, and then implement velocity and acceleration as variables that you change in script.




I didn't know that! How are you thinking here in terms of scripting is it an object instead of a character perhaps? I do get a warnings.txt in the game folder when using character.setwalkspeed while still "cBus.Walk"'ing the vehicle.


AndreasBlack

#7
Bringing up an old thread, so i started the insane task (laugh) yesterday of trying to do a "suedo 3d effect wheel rotation" without actually using 3d. I think it turned out pretty cool! I rotated the image 18° clockwise then re-sized it to 400% nearest neighbour, eyeballed the wheel spinning somewhat. Since were dealing with pixelart here (mostly, i think?). I do that because i don't want a blurry anti-aliased messy look. If you use transform tool that is what will happen if the resolution is low. 

After doing that i imported all the sprites 20 png's into AGS (to save time i just used transform tool and flipped 10 frames using horizontal/vertical tool in Photoshop to get the full 360) and manually scaled it down in AGS to fit the "320x200 resolution Thumbleweed look". Decent enough for something that you see in 2seconds or less ;) Way better then 2 or 4 frames flipped with vert/hor tool in Photoshop like i've tried before, at least to my eyes (roll)

The only thing i don't like atm is i need to figure out how to use the tweenmodule to fix the animation speed matching the float of the tweenpositioning i do with the moving object (wheels) acceleration :-[. But that's nitpicking. Here is a gif of the result.

I looked in AGS 3.6 but i couldn't find any "object.rotation" or such syntax i guess it's not available yet. Are we talking a distant future for sprite rotation or is it far away? I don't try beta's alpha's and all those things, too scared to mess up my main project files! (laugh) 



http://i.imgur.com/qL1vgHB.gifv

Crimson Wizard

Quote from: AndreasBlack on Fri 15/09/2023 11:40:44I looked in AGS 3.6 but i couldn't find any "object.rotation" or such syntax i guess it's not available yet. Are we talking a distant future for sprite rotation or is it far away? I don't try beta's alpha's and all those things, too scared to mess up my main project files! (laugh) 

This is implemented in AGS 4, for objects and characters this property is called GraphicRotation.

Khris



This isn't the critics lounge, but given the great sprite art I have to say I'd probably only rotate the wheel without the lighting, then paste that on top at 50% transparency or something like that.

AndreasBlack

#10
Quote from: Khris on Fri 15/09/2023 13:03:14

This isn't the critics lounge, but given the great sprite art I have to say I'd probably only rotate the wheel without the lighting, then paste that on top at 50% transparency or something like that.

No worries! That's actually a great idea! Alltho i would have to re-make the entire animation, which sucks. Since it's not in layers unfortunaly :~( Edit: Never mind, i could actually just use the bucket tool, the pixels are still pretty clear thanks to resolution. Great! I'll edit it a bit later just darken it a bit..

Perhaps have the lightning layers in the actual room with Straight matter as an object itself?! So when the car drives by it. It reacts to it, sorta like a "lights/lamp layer" ??? But that's in the future now i have to finish more of the game, been slacking so much to do! Lots of BG's left to draw, etc. Thanks for your feedback tho, much appreciated as always! (nod)

SMF spam blocked by CleanTalk