[Lua] How to 'resize' vgtStraightShot?

13 replies [Last post]
UltiMaxKom
UltiMaxKom's picture
User offline. Last seen 7 weeks 39 min ago. Offline
Joined: 2016-06-26
Posts: 363

Hello, I'm here again with a question
Lemme get this short, I have not-so-much time here (not really lol)
Okay so, about ~two week ago I asked nemo some questions
Questions about our Hedgewars GFX and SFX manipulation capability
Yeah, such a regular Ulti's topic, I'd say
This topic ain't going away for such awhile though, hehe
(Although, tbh we still need SO many polishing to do on this issue, but nvm)

For this post purpose
I wanted to say that nemo tell me that we can resize visual gear in HW
Although I didn't really remember is vgtStraightShot one of em' or not
But I'm sure it must be included as a resizeable visual gear
alongside with vgtCircle because vgtStraightShot are very-very used in HW
BUT unfortunately however, recently I found no way for one to resize vgtStraightShot
It is either I just simply don't know exactly how, having too low IQ or--I hope not--: It is impossible to do
I'm not really sure but AFAIK:

local vg = AddVisualGear(x, y, visualGearType, state, critical [, layer]) ; 
SetVisualGearValues(vg, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint)
--[[
With (For vgtStraightShot):
vg: vgUid
X: X coordinate position
Y: Y coordinate position
dX: X axis velocity
dY: Y axis velocity
Angle: vg facing angle (360' deg base, with 90' deg being perpendicular to X axis)
Frame: Used/Initial frame (?)
FrameTicks: Lifespan until automatic fade-off (?)
State: Sprite used (spr)
Timer: Welp, I forget this one, and too lazy to re-check xD
Tint: Color in RGBA (Can use HEX values)
--]]

Well, this^ all I know atm

And at this particular moment, I wanted to ask
How to resize vgtStraightShot? (omg, the title already explains a lot...)
I hope someone could lend me a hand, and I hope a/some devs are one of my savior x)

PS: I HOPE THIS ISN'T THE 'BIG MISTAKE&ACCIDENT' CASE LIKE ONE I'VE DONE BEFORE (LMAO)

( 'ಠ_ಠ)▄︻̷̿┻̿═━一 ̿̿ ̿̿ ̿̿ ̿'̿'\̵͇̿̿\з= ( ▀ ͜͞ʖ▀) =ε/̵͇̿̿/’̿’̿ ̿ ̿̿ ̿̿ ̿̿ ᕙ(⇀‸↼‶ )ᕗ

nemo
nemo's picture
User offline. Last seen 1 hour 18 sec ago. Offline
Joined: 2009-01-28
Posts: 1650

Scale - that's what the bounce graphic uses with vgtStraightShot - but... Bad news for you. For some reason I didn't add SetVisualGearValues - I really thought I had. Sorry.
Maybe I added that value after. I can add it, but, next release etc :/

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

UltiMaxKom
UltiMaxKom's picture
User offline. Last seen 7 weeks 39 min ago. Offline
Joined: 2016-06-26
Posts: 363

@nemo
I really appreciate it, thanks man =)
Even though, hmm, it'll come in next release which is totally not a problem
Just remember to add one hehe, also if can fix the custom# sprites framing design
I mean, it'll be great to able to (at least manually) animate our graphic without templating other important things (ahem)
Hehehe

Oooooooh!
ALSO! I realized something here (just at this insta)
nemo, why did the angle run between 0 - 360 ? Is it designed this way or?
Because I think you guys said Hedgewars used about ~8000s precision value for angles
Hmmm... I'm not sure though, but I think that is er =/
Please clear this (coincidentally occurring) clouds in my head =[
Even though it won't be a problem either way (?)

Ok ok, only need some patience UltiMaxKom, and you got it all!
Ver.0.9.25 here I waitin'!
Thanks to all you devs tho ^^

( 'ಠ_ಠ)▄︻̷̿┻̿═━一 ̿̿ ̿̿ ̿̿ ̿'̿'\̵͇̿̿\з= ( ▀ ͜͞ʖ▀) =ε/̵͇̿̿/’̿’̿ ̿ ̿̿ ̿̿ ̿̿ ᕙ(⇀‸↼‶ )ᕗ

KoBeWi
KoBeWi's picture
User offline. Last seen 6 hours 8 min ago. Offline
Joined: 2010-12-25
Posts: 464

UltiMaxKom allegedly wrote:
nemo, why did the angle run between 0 - 360 ? Is it designed this way or?
Because I think you guys said Hedgewars used about ~8000s precision value for angles
0-360 range is for convenience (that's how you specify degrees usually), but I bet you can use fractions too, e.g. 120.003 or 3.25

UltiMaxKom
UltiMaxKom's picture
User offline. Last seen 7 weeks 39 min ago. Offline
Joined: 2016-06-26
Posts: 363

KoBeWi allegedly wrote:

0-360 range is for convenience (that's how you specify degrees usually), but I bet you can use fractions too, e.g. 120.003 or 3.25

I do (kinda) agree with you KoBeWi, about the range convenience.
But devs (unCORr(?)) said Hedgewars handle angle with ~4000 precision values as a half a full turn--Thus, it's about ~8000 for a complete turn-- when I active an ages ago in IRC (so please correct me if I remember it mistakenly, I'm a Human fyi). So that's makes me thinkin' =/
Hmmmmmm...

PS: If one needs an example, please check 'Angle' value by 'GetGearValues' function (idk/I'm not sure what would be the result lol, this makes two of us xD (lazy af to check here (help me...)))

Also KoBeWi, I think you/we shouldn't use Float Values (i.e fractions for angle) in Hedgewars (In most case)--well, nemo could explain why.

Anyway, good to see you man! I'm quite curious of your RPG project, though! Please lend me more teaser/info ^^
(well, there's a function 'onUsedAmmo' in Hedgewars now, so I guess your works can be continued, not like mine that stuck on this scaling issue, again =/ hehe )

( 'ಠ_ಠ)▄︻̷̿┻̿═━一 ̿̿ ̿̿ ̿̿ ̿'̿'\̵͇̿̿\з= ( ▀ ͜͞ʖ▀) =ε/̵͇̿̿/’̿’̿ ̿ ̿̿ ̿̿ ̿̿ ᕙ(⇀‸↼‶ )ᕗ

nemo
nemo's picture
User offline. Last seen 1 hour 18 sec ago. Offline
Joined: 2009-01-28
Posts: 1650

So, visual gears don't use the synced math mechanism, so 0-360 standard floating point is fine.

Regular gears need to be synced so they use ints and hwfloat.

Some of this junk leaks through uScript since we don't bother abstracting it much.

So. For synced gears there is:
https://hg.hedgewars.org/hedgewars/file/tip/hedgewars/uTypes.pas#l278
// DirAngle is a 'real' - if you do not need it for rotation of sprite in uGearsRender, you can use it for any visual-only value
DirAngle: real;
and
Angle, Power : Longword; // Used for hog aiming/firing. Angle is rarely used as an Angle otherwise.

DirAngle is same as with visual gears - just a floating point value passed directly to opengl for drawing whatever is rotating (usually just something tumbling like a grenade)

Angle is the fixed point synced math. For example AngleSin does:
if Angle < 1024 then AngleSin.QWordValue:= SinTable[Angle] else AngleSin.QWordValue:= SinTable[2048 - Angle] end;

and where the lookup is here:
https://hg.hedgewars.org/hedgewars/file/tip/hedgewars/uSinTable.pas

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

UltiMaxKom
UltiMaxKom's picture
User offline. Last seen 7 weeks 39 min ago. Offline
Joined: 2016-06-26
Posts: 363

@nemo D'oh!
Welp, you didn't tell me this when you tell me not to use floating points =/
IN HEDGEWARS (including vg ofc)
Hmmm, would it be good for me to rearchitect my anti-floating-pointdexter? Maybe half-yes.
Nvm; everything's fine...

So nemo, it's fine to use floating values now =D ? Hihihihihi *commencing evil laugh*
Muahahahaha!!!!! (This is UltiMaxKom's subconsciousness: kill me...)
*clear throat*
I mean, thanks for clearing things up ^^

@KoBeWi
With my teaser request: If you uploaded it already, please let me know, ahem, the link *wink*

( 'ಠ_ಠ)▄︻̷̿┻̿═━一 ̿̿ ̿̿ ̿̿ ̿'̿'\̵͇̿̿\з= ( ▀ ͜͞ʖ▀) =ε/̵͇̿̿/’̿’̿ ̿ ̿̿ ̿̿ ̿̿ ᕙ(⇀‸↼‶ )ᕗ

KoBeWi
KoBeWi's picture
User offline. Last seen 6 hours 8 min ago. Offline
Joined: 2010-12-25
Posts: 464

UltiMaxKom allegedly wrote:
Anyway, good to see you man! I'm quite curious of your RPG project, though! Please lend me more teaser/info ^^
(well, there's a function 'onUsedAmmo' in Hedgewars now, so I guess your works can be continued, not like mine that stuck on this scaling issue, again =/ hehe )
Ah, this. I was ultra busy recently. I added the onUsedAmmo thing and implemented lots of stuff. I think I stopped when I needed some onHogHeal function, because I was trying to make shared Vampirism. Uh, I'll need to dig up the project again after long hiatus to see how far actually I'm from finishing it (I almost forgot about this, lol).

UltiMaxKom
UltiMaxKom's picture
User offline. Last seen 7 weeks 39 min ago. Offline
Joined: 2016-06-26
Posts: 363

"Ultra-Busy"? I CAN RELATE, REAL DEEP :U. So you implement many stuff eh? I wonder that yonder :O (tease hihihi). I believe your gamemode would be cool as funge, no doubt asked.

And about the "Hiatus" welp, I relate this real deep, TOO!
I really&really^100 hate Hiatus for hog sake. Seriously, if I could met Hiatus in person, even though one couldn't; cuz 'its' not a person. I really could kill it with a friggin' spoon I tell ya! I'M SO FURIOUS ARRR!!! Not just because I had so many yet so long hiatus in my project (too lol). My fury also impersonates the time I've used waiting for my shows franchise' next episode!. Dagnabbit! Why D: God why D'; ?! *cryababy*. Okay okay, I'll try to control myself *sob sob* ='/

I'll just hope the best for you and me to destroy them cursed hiatus! (ahem, my subconsciousness doubt for the part "me"). And let's us finish our works! Muahahaha *cough cough* h-hahaha!
*COUGH...*

NOW LET'S ROLL YAR NOTEPAD++ \(▀̿Ĺ̯▀̿ ̿)/

( 'ಠ_ಠ)▄︻̷̿┻̿═━一 ̿̿ ̿̿ ̿̿ ̿'̿'\̵͇̿̿\з= ( ▀ ͜͞ʖ▀) =ε/̵͇̿̿/’̿’̿ ̿ ̿̿ ̿̿ ̿̿ ᕙ(⇀‸↼‶ )ᕗ

nemo
nemo's picture
User offline. Last seen 1 hour 18 sec ago. Offline
Joined: 2009-01-28
Posts: 1650

Just a reminder to people who want to slap code in for us to look at. I added a draft repo, can give anyone access who asks...
Just drop by the chat.

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

UltiMaxKom
UltiMaxKom's picture
User offline. Last seen 7 weeks 39 min ago. Offline
Joined: 2016-06-26
Posts: 363

@nemo
If you're going to add the VG resizing feature to HW.25 (which I hope you will), then please to make it "Resize" features for x-axis and y-axis separately, and not a "Scale" feature where it resizes both x and y-axis at once. I mean, all visual gear's width and length should be resizeable independently from each other for better manipulation (A parameter to resize x-axis and another parameter to resize y-axis). And yes, as I said before, that I REALLY REALLY hope the new feature works for every visual gear, including our limited n' replaceable customs VGs =D. (Imagine if I wanted to make a laser weapon (which I will, hopefully), then I could just simply make a single dummy custom VG then stretch it as far as the laser go instead of spawning hundreds of hundred VGs along the line which is a resource-wasting method, all thanks to the useful feature =))
Thanks for your understanding ^^

( 'ಠ_ಠ)▄︻̷̿┻̿═━一 ̿̿ ̿̿ ̿̿ ̿'̿'\̵͇̿̿\з= ( ▀ ͜͞ʖ▀) =ε/̵͇̿̿/’̿’̿ ̿ ̿̿ ̿̿ ̿̿ ᕙ(⇀‸↼‶ )ᕗ

nemo
nemo's picture
User offline. Last seen 1 hour 18 sec ago. Offline
Joined: 2009-01-28
Posts: 1650

hm... I thought we had the line drawing routine exposed to lua already (WRT laser).

Also, if you make VGs go fast enough, you end up w/ a projectile stream w/o having to stretch anything.

I think stretching a sprite really long could look pretty ugly depending on the scale/card/sprite.

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

UltiMaxKom
UltiMaxKom's picture
User offline. Last seen 7 weeks 39 min ago. Offline
Joined: 2016-06-26
Posts: 363

nemo allegedly wrote:

hm... I thought we had the line drawing routine exposed to lua already (WRT laser).

Also, if you make VGs go fast enough, you end up w/ a projectile stream w/o having to stretch anything.

I think stretching a sprite really long could look pretty ugly depending on the scale/card/sprite.


1] To be real honest, Idk how to make that 'WRT laser' =/
Welp, I should know this D= !

2] Well anyway, the laser thing is just an example. The main reason with stretching feature is that it's just definitely better than plain diagonal scale. Or if can't change the scaling then just add two more params for the individual x and y resize while leaving the scaling untouched (if the problem of implementing this feature is that the scaling is already been implemented). Anything to make it work is the best.

Another example is that I can make a portal by stretching a plain circle! Or, for making a silly lightning cannon that shoots lighting jumps, which using a single electrical image stretched accordingly and rotated until the starting point and the ending point match the caster-to-target (take a lightning from the internet then modify till the lightning is all we can see covered in transparency, then manipulate it in Hedgewars). And more!?

3] Yeah, it can be ugly (hihihi, imagining memes got stretched so badly x)). But if I stretch an image with a single color? Like a square of total white, then stretching it horizontally xor vertically won't be a much of a pain (as long as the stretching isn't too extreme), right? I'll just combine the stretch feature with rotation feature, then everything's possible *insert WOW here*

] Thanks nemo ^^

PS: Also, moving a VG so fast to mimic a laser is more like a bullet than a laser (The laser here is a constant, moveable, persistent columns of beams. These two need to be different tho). Though, it would be cool regardless =D

PS+: Do you know about Minigun bugs on its laser/bullet? I mean, the one that going the wrong angle, not to what we're pointing at. Even though the effect caused is still right (land/hog damage still going the right direction, it just the bullet ray going the wrong angle). I hope you've already know/fixed this =) thanks

( 'ಠ_ಠ)▄︻̷̿┻̿═━一 ̿̿ ̿̿ ̿̿ ̿'̿'\̵͇̿̿\з= ( ▀ ͜͞ʖ▀) =ε/̵͇̿̿/’̿’̿ ̿ ̿̿ ̿̿ ̿̿ ᕙ(⇀‸↼‶ )ᕗ

nemo
nemo's picture
User offline. Last seen 1 hour 18 sec ago. Offline
Joined: 2009-01-28
Posts: 1650

WRT minigun bug, it was probably https://hg.hedgewars.org/hedgewars/rev/13381 or https://hg.hedgewars.org/hedgewars/rev/13321

Feel free to check in latest dev, can use more testing anyway.

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

Copyright © 2004-2017 Hedgewars Project. All rights reserved. [ contact ]