Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - TheManInBoots

#141
Edit: Actually I noticed that the offsets only happens when I rotate by certain degrees, so when I rotate 90,180,270 degrees there is no offset.

So I think I still need to experiment a little with this, since the reason does not appear to be rotating multiple times, but by what degree one rotates.

Spoiler


This was the original post

I am rotating object sprites, using dynamic sprites.

The first rotation works fine. But when I rotate it a second time, there is a little offset, it's about 33 pixels too far to the right and up.

The script I used:

In the script body:
Code: ags
DynamicSprite* shower;


Then in room after fade in:
Code: ags

shower=DynamicSprite.CreateFromExistingSprite(723, true);
shower.Rotate(90);
oindicator.Graphic =shower.Graphic;
Wait(20);

shower=DynamicSprite.CreateFromExistingSprite(723, true);
shower.Rotate(47);
oindicator.Graphic =shower.Graphic;
Wait(20);

shower=DynamicSprite.CreateFromExistingSprite(723, true);
shower.Rotate(154);
oindicator.Graphic =shower.Graphic;
Wait(20);

shower=DynamicSprite.CreateFromExistingSprite(723, true);
shower.Rotate(238);
oindicator.Graphic =shower.Graphic;
Wait(20);


So the first time it rotates normally the way I want it, too, and from the second time on there is this offset there.
I can fix it by simply moving the object 33 pixels left and down (-33 pixels on x-coordinate,  33 pixels on y-coordinate) after the first rotation, but I would like to understand why this happens in the first place, so that if I have more complicated things to rotate, I can calculate and asses exactly how big the offset is going to be, and not just fix it by eye sight and estimating the offset.
Does anyone have an idea why this happens?
It's exactly the same when I draw overlays instead of object sprites...
[close]
Thanks
#142
Olleh, serious question, were you on drugs while you wrote this?
(laugh) ok, I'm just kidding!
But honestly, this is a very confusing thread.
I might not be the perfect communicator myself, but if you're genuinely looking for help for the issues you're having, I think a good start would be to re-write the entire thread. Because it almost sounds like a prank with all the confusing elements, even though this might not have been your intention at all.

Examples of confusing parts:

Quote from: Olleh19 on Sat 29/02/2020 01:25:14
And another thing. The NPC does some quite ANNOYING SOUNDS  (laugh) and the room is rather large,
so it would be nice if one could just perhaps mute the sound, aswell as his random talking/texts in the bakground.
Noone knows what you mean with annoying sounds.
Why does it matter that the room is large?
It is all totally unclear from what you say.

Quote from: Olleh19 on Sat 29/02/2020 01:25:14
What happens now is that the talking is shown on the screen even tho i left the NPC "in a galaxy far faaar away".
So it would make sense for A. He stops his animations/moves temporarely (i've tried that, unsuccessfully, as code here will show) :-D
So again, when you say "in a galaxy faar away", nobody understands what you mean. Is it just a metaphor, or part of the game plot?

Also, who is A.?
What do you mean, he moves temporarily? And what is he supposed to do instead? What did you try unsuccesfully?



So, my advice would be to re-write the entire thread, start by describing only one problem at a time, and when it's solved, you can start tackling the next problem.
The way you described everything at once it becomes completely unintelligible.

And when you address the problem, start by describing clearly what you want to create, then what you have created so far and where the current problem lays that you're unable to fix. So people know how to help you.


But I guess thanks, this is a good example on how not to write a thread for the technical forum.
And it's no problem, we're all here to learn and improve. ;)
But if you want people to be actually able to help you, you will probably have to re-write your thread!
#143
Concerning scripts that do not work and functions that can't be found, I also noticed this:

When you blend out the end of Global Script.ash with a slash asterisk(/*), but you don't close it and leave it open,
you will get plenty of error messages in other scripts.

For example I got
QuoteUnexpected "{"
in Global Script.asc

Or after I removed something in Global script, then the error message for room_before_load function. It said there was no such function in script for room 9.

So you can completely mess up the scripts, and functions won't be recognized anymore, when you leave an open slash asterisk in Global header.
All problems were gone after closing it with */

Since we were talking about functions not being read properly I thought I'd add this.
#144
Jackputter,

I have respect for the fact that you had the discipline to finish your first game, since from what you say you seem to be starting out! :)
The screenshots look already neat!
Welcome to the forum!
#145
Quote from: Khris on Wed 26/02/2020 17:06:19
The ellipse button not jumping to the function is something that happened to me once IIRC when I was working with a really long global script. Thousands of lines, and jumping to the function wouldn't work for functions way down near the end.
Crimson Wizard, so apparently?
#146
Sorry about the bad news Durinde.

Stupot,
so did I understand you right, the deadline is March 2nd at 23:59?
#147
Yeah, I just mean, explaining it is enough.

The way you said it initially, it sounded more like an order than an advice, even if it was intended as an advice.
I think you improved it and it sounds better now.
The right communication is important as well, to convey the proper message.

It is just by coincidence that "function" can be used to declare ints in AGS.
It is not the proper way to code your script.

I know this. And even Crimson Wizard's explanation was already enough to convey it.

Since I know this, playing around with it wasn't like eating dog shit on a pizza.
It was more like noticing the bread on the pizza tastes like vanilla, and pretending that it's vanilla ice cream.

It's just playing around and having fun.
There's nothing wrong with playing and fooling around.
It stimulates creativity, instigates new ideas and it is the most natural way to create a deeper understanding of the world, or in this case, the AGS engine.

That's why I said, you can relax a little. It's just playing around after all.
#148
Yeah makes sense, and of course Khris was talking about the function being the second part of the expression (namely Cubervoot()). not the entire expression being a function, now that you say it Crimson Wizard.

Haha, Khris, this stuff with function is very interesting to me, even if I don't use that in game scripting.
I don't have to unlearn it at all, because I know what is useful and works, even when I know more stuff like this on the side.
Besides it teaches me about the nature of script transitioning to newer versions.
Exploratory mind doesn't stop with what's rule bound.
Also, I think you should relax a bit before telling me that I should unlearn that immediately. That's too krass.
Some people just do things differently and you don't need to wrap your head around it and can just accept it.

Crimson Wizard, a philosopher might start hypothesizing if philosophy is a better approach to programming than maths haha. But let's not go there.

I really appreciate your explanation. I don't have the time to reply to it for now.


I'll just leave the solution to the problem I stated above:

How to make it so that both up and side mouse movements trigger different action at the same time:


X and y savemouse coordinates are reset every ten pixels. The problem was that I reset the savemousey in the mouse x-movement bracket and vice versa.
When I calculate the x-movement, I only need to reset savemousex, and the same for y-movement.
This way the two of them are independant and can run at the same time.
Otherwise one direction will never be triggered because the direction in which the mouse moves faster resets the coordinates before the second direction triggered.

So, renewed script, just remove two lines and it works (I removed lines 23 and 42):

Code: ags
 

//Mouse moves horizontally more than 10 pixels
      if (mouse.x - savemousex > 10||mouse.x - savemousex < -10) //I also had to add when the difference is smaller than -10 (for left movements)
      {
        
        if (mouse.x > savemousex)
        {
          //mouse moving right
          if(cJim.Frame!=18)
          cJim.Frame=cJim.Frame 1;
          else cJim.Frame=1;
        } 
        
        else 
        {
          //mouse moving left
          if(cJim.Frame!=0)
          cJim.Frame=cJim.Frame-1;
          else cJim.Frame=17;
        }
        savemousex=mouse.x;//Reset of saved mouse coordinates
        //removed: savemousey=mouse.y;

      } 
    

    //Mouse moves vertically more than 10 pixels
      if (mouse.y - savemousey > 10||mouse.y - savemousey < -10) 
      {
        
        if (mouse.y > savemousey) 
        {
          cJim.y=cJim.y 40;
          //Animation code for mouse moving down goes here
        } 
        else 
        {
          cJim.y=cJim.y-40;
          //Animation code for mouse moving up goes here
        }
        //removed: savemousex=mouse.x;
        savemousey=mouse.y;
      }
#149
Yeah, okay, but re-importing the gui does not change the length of the script, which Khris mentioned at the end of his comment as being a potential reason for the ellipse button not jumping to the right point in script.
Olleh, is that project you have something you'd be willing to share or send me in any way?
It's out of pure curiosity for me to explore that problem for the guis as well for myself.
I might not get any great insights, but somehow I would like to try to understand this better still.
#150
I would like to be able to learn from this, too, and I'm not sure I understood everything.

So, it was not working because the script was too long, and so the gui/button related functions could not be called anymore on the bottom of the script?
And the solution is to import those functions into a different, shorter script?

Did I get the basic gist right like that more or less?
#151
Crimson Wizard,

Since, originally in C language, one has to assign the return value for each function, the key word "function" is simply a substitute for the int value, and is that not enough reason for that to work to declare an int with it?
Khris mentioned that the expression
Code: ags
float side = Cuberoot(volume); 

is basically a function that returns something but does not do something.
In that case
Code: ags
int number=3;

Can be considered a function that only returns a value and does nothing, and since int defined functions can be replaced with the key word "function", it should be obvious that you can also write
Code: ags
function number=3;

instead.
When you say for "compatibility reasons" you are not talking about the afore-mentioned,are you?

Khris,

Yes, morganw explained that very clearly that "function" substitutes "int".
But I really appreciate all the examples you give. Context is extremely helpful, and the next thing I want to try when I got time is experiment with functions that return a different value than int, so your examples are really useful!

I also think that's why CJ did it.
When you say void functions are called on their own, what do you mean with "on their own"?


Thanks
#152
That's interesting!

For one, I see I can declare an int using "function".

Code: ags
function number=3;


And then I can use "number" as an int.

I will experiment more with this when I have the time.

Thanks
#153
Oh yes, I forgot that in that moment.
#154
Quote from: Olleh19 on Wed 26/02/2020 16:14:39
I'm unsure what to answer.

If i type in the function in the script (btnSave_Click (GUIControl *control, MouseButton button)


And to the left of the ellipse button you also have written btnSave_Click, the same thing?
#155
I'm just gonna state the obvious thing:

For the elipse button to ignite the code the name to the left of the elipse button needs to be the same as the name in the script.

For example if tothe left of the elipse on click button there is written: "btnSave_Click",
that means you need in the script a function with the exact same name:
Code: ags
function btnSave_Click ...


Secondly, maybe the way guis are assigned (with pointers or not) or something similar has changed over time.
The second part of the function description should say:
Code: ags
(GUIControl *control, MouseButton button)


So together
Code: ags
function btnSave_Click (GUIControl *control, MouseButton button)
{

}


Then you can write whatever you want in the curly brackets and it will be triggered.

So

1.) Check the function name
2.) Write (GUIControl *control, MouseButton button) in the brackets right after.

Is that all correct in your script, or is the probelm something else?
#156
If nightmarer changed the background, he had to redraw the walkable areas.
Also he might have actually changed it to a different background where the walkable areas lay in a different place.
Either way he had to redraw the walkable areas, and now the character coordinates lay on the walkable area and the character walks.
That's the only explanation.
The character just looked as if he was standing on the walkable area, or nightmarer had actually drawn walk behinds the first time.

Maybe nightmarer, you would like to share a sprite of the character, just to see if there's a big offset (a big gap) on the bottom of the sprite?
In this case it might have been that the character didn't actually stand on the walkable area.
#157
How do you call this way of creating the abs function btw. if I want to learn more about it?
It's not really an array, but it's not really a custom function...
Is it AGS code or part of C language?
#158
Yes I was refering to the abs in the code.
Got it, thanks! That's why he didn't write 10 and -10 what I added.
#159
Normally you shouldn't have to activate anything else.
Most likely your character is not really on the walkable area.

When your character has an offset, so when the character is not really on the bottom of the sprite, it can happen that it looks like the character stands on the walkable area, whereas in fact he stands below.

So that's the first thing I would check.
The easiest way for you to check that is to go to the Room Editor for room 2 and move the mouse to the positions 99, 455 and 500, 455 (the mouse position is indicated in the left top corner of the editor). And if at that spot where the mouse is you have a walkable area, then you know the walkable area is correct. If not, you found the problem.
#160
Okay, I like your approach. When I tried it I worked with timers, so when the mouse changed far enough after a period of time the animation code would be triggered.
But that did not work at ALL reliably lol. So I really like how you only work with space, and not time. I had to change a few things in your code to make it work.

Here is the changed code:

Code: ags
 
//I actually would like the horizontal AND vertical mouse movement to trigger something at the same time so I removed one 'if' condition of yours

//Mouse moves horizontally more than 10 pixels
      if (mouse.x - savemousex > 10||mouse.x - savemousex < -10) //I also had to add when the difference is smaller than -10 (for left movements)
      {
        
        if (mouse.x > savemousex)
        {
          //mouse moving right
          if(cJim.Frame!=18)
          cJim.Frame=cJim.Frame 1;
          else cJim.Frame=1;
        } 
        
        else 
        {
          //mouse moving left
          if(cJim.Frame!=0)
          cJim.Frame=cJim.Frame-1;
          else cJim.Frame=17;
        }
        savemousex=mouse.x;//And then after a movement of ten pixels and the animation has been triggered, I had to reset the savemouse ints, obviously
        savemousey=mouse.y;

      } 
    

    //Mouse moves vertically more than 10 pixels
      if (mouse.y - savemousey > 10||mouse.y - savemousey < -10) 
      {
        
        if (mouse.y > savemousey) 
        {
          cJim.y=cJim.y 40;
          //Animation code for mouse moving down goes here
        } 
        else 
        {
          cJim.y=cJim.y-40;
          //Animation code for mouse moving up goes here
        }
        savemousex=mouse.x;
        savemousey=mouse.y;
      }



So what I changed:

  • I removed one 'if' condition
  • I added the condition for mouse position difference<-10
  • I added the reset of the savemouse ints after each 10 pixel interval

(I tried using a pointer instead of two ints, but that makes things complicated because of null pointer references.)
Now, first off it works, the character animates with horizontal mouse movement, and moves with vertical movement. So thanks for the basic idea. But there are two problems I still face with that:
Up and down movements are not triggered the same way. So the character travels faster up than he does down. Even though it's set to change the y-position to  40/-40, so in theory it should be the same. Does anyone have an idea how that could be fixed?

And then I have another problem: horizontal and vertical movements are never triggering at the same time. I would like that to change. I would like them to be triggering at the same time. So that you can move mouse only right, or right-up, or left-down etc. (causing animation, or animation AND movement...)
However that does not work, even though I removed the if bracket that was meant for that. And I don't want an if condition for EACH direction combination to be honest...

I tried placing up movement and side movement, one in repeatedly always, and one in late repeatedly always, that did not work.

So if anyone has an idea how it can be done, let me know :)


On a side note: AGS does not work with absolute value functions so I had to remove them anyways. But even on a different platform, why would you use an absolute value function for something as simple as a substraction? Is there something I'm not seeing?


Thanks
SMF spam blocked by CleanTalk