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.

Messages - froz

Pages: 1 2 3 ... 17
Ah, so you want to zoom in/out dynamically during game? You can try the behaviour "zoom scene" from stencylforge. But again, I haven't used it, not sure how that works.

You can change scale in settings. I have never used that though, so I'm not sure how it works.

If you want an actor you create to have a center at x,y, you need to create it at x minus half-width of that actor and y minus half-height of that actor. Since "width/height of self" blocks allow you to choose "half-width" etc. there is no need to manually divide it by 2.

So, what TDonnally set, except you need to diminish, not add half-width and half-height.

Resolved Questions / Re: Multi-line text boxes?
« on: July 24, 2013, 04:57:21 am »
I haven't used the "create new list" block because I still do not understand why or where I need it in the code. Please keep in mind that I'm a beginner with this software so I'm not familiar at all with lists referencing looping dynamic lists. It's very surprising that the text behavior downloaded from Forge was so horribly broken. So far I have three lists running in the code.
If you want to learn, read stencylpedia. I have provided you a link to the article about lists and "create new list" block is explained there. There are tons of other useful articles in the stencylpedia.

Ask a Question / Re: Time Behavior Not Working
« on: July 23, 2013, 11:26:59 am »
There is no loop in the code you shown. "Do after" is not a loop, so it will just run once. "Do every" is a loop.

Resolved Questions / Re: Multi-line text boxes?
« on: July 23, 2013, 11:25:01 am »
You are still not using "create new list" block. Did you read the article about tables I linked in my last post?

As for other problems - there are some fundamental mistakes you make. For example, you need to understand how drawing works.

Everything in "when drawing" happens 60 times per second (every frame). If you need text to be drawn, it needs to be drawn 60 times per second. However, calculations of the text does need to be done only once, when it is created/changed. So - you need check if the list was prepared and run the code to prepare it only if it wasn't prepared or it needs to be changed. Furthermore, you need to separate drawing from calculating, because you need to draw the text every frame.

It is good habit to always start drawing with blocks setting the drawing space (in this case switch to scene space).

You can and should use "print" blocks to check if everything is working as you expect it. Print block will "print" whatever you put inside in the console log (accessible with ~ key in the game). This can be very useful and it could answer your questions.

In general, when you start using an attribute that you don't want to be "remembered" for later frames of the game, you should start using it by (re)setting it something (like you set New Line to 0). You don't set Current Line to 0, but you should, don't count on that it will magically be back to 0 on the second frame of the game.

Resolved Questions / Re: Multi-line text boxes?
« on: July 22, 2013, 09:43:47 am »
You should draw each line separately (each text attribute, not the hole list attribute) and move pen some pixels lower every line.

And the "create new list" is a code block. Check this article about lists:

Ask a Question / Re: Attaching a actor + rotation
« on: July 22, 2013, 05:32:13 am »
You need to calculate turret positions based on the ship direction. Actually it's not that hard, but you need to use some trigonometry.

How? You can calculate a point in the circle with a simple formula. x position of the point = cos (angle to the point) * radius (distance to the point). y position of the point = sin (same angle) * radius (same distance).

So, you need to know angle to the point and distance to the point. Distance should be the same as the original distance and you can calculate original distance by using a2 + b2 = c2. Meaning - distance on x axis2 + distance on y axis 2 = real distance. In stencyl it looks like this:
sqrt[x_distance^2 + y_distance^2]

How to calculate the angle? You need to calculate original angle then add ship's direction to it. To find original angle use atan2 block (atan2[y_distance, x_distance]). When you add direction, remember to transform direction to radians (use block "as radians"), because sin/cos blocks takes radians, not degrees and also atan2 block gives radians, not degrees, however direction block gives degrees, not radians.

x_distance and y_ distance should be x and y distance from the ship center to the turret center. All those calculations will give you x_center and y_center of the turret, so you need to diminish half-width to x and half_height to y to get x/y position.

Ask a Question / Re: Getting the right approach to programming
« on: July 22, 2013, 05:13:11 am »
You need to think what exactly the programm needs to check and do to achieve the goal. As you can see, on this map, the robot needs to turn left and move forward whenever there is a path to the left, if there isn't, he needs to go forward if there is a path ahead, if it also isn't there, he needs to turn right and move forward. He needs to repeat those steps till hi finds the exit.

Now you need to figure out how to put that into code blocks. I don't want to spoil it for you, but remember you can put code blocks inside another code blocks and it will be needed here.

Resolved Questions / Re: Multi-line text boxes?
« on: July 21, 2013, 03:43:16 am »
Make it yourself, you have to split the string into words, then check if the word fits on the line, if not, make a new line. use the 'get width of __ using font __' block in the drawing section.
Good luck, be a great opportunity to learn how to use the design blocks.

If you're really struggling (and i mean struggling, not just being lazy) i can give you some help, i have had to do this before and it proved quite taxing:)

I'm relatively new to this program, but this is what I have so far. All it seems to do is give me 1 second of lag and no text to show for it.

There is no block to actually draw text in the code you showed us. The mechanic to prepare the text looks ok, though you should only calculate it once when needed, not every frame (what rob said) and it is good to always create new list by "set listattribute to [create new list]". Otherwise it sometimes doesn't work like expected, at least for me.

You need to use internal names of attributes (in the blocks "for last created actor set something for behaviour"). Easiest way to make sure you don't make a mistake when writing an attribute internal name (and behaviour name) is to click on the little arrow in this block and choose "attributes names > behaviour name > attribute name" from the dropdown menu.

Resolved Questions / Re: Deciding Between Overlapping Actors
« on: July 15, 2013, 07:56:57 am »
You definitely should not ignore this. I can't say why exactly it is happening, but probably somewhere in your code you are trying to access an actor which is not existing.

You can read about problems like this here:

Resolved Questions / Re: Deciding Between Overlapping Actors
« on: July 15, 2013, 05:05:02 am »
You could register the click in the scene behaviour (not the tower actor behaviour).

Something like this

Code: [Select]
if mouse was pressed
   {set y to scene-height
     for each actor of type towers
      {if mouse was pressed on actor
         {if y-position of actor > y
            {set y to y-position of actor
              set clickedActor to actor
       } trigger event for clickedActor (to open menu or whatever you want)
What this should do:
1) work only when mouse was pressed
2) check each actor to see if mouse was pressed on the actor. If it was, check if this actor y the lower then any other clicked actor (as you first compare to screen height and later to any other clicked actor)

Another, maybe easier way this could be done is by creating additional, square, invisible actor (in create event for tower actor behaviour) and checking if it was clicked. This square actor would need to have physics disabled (as I guess you also disable physics for tower actors). The downside of this method is that the player would always need to click on that square at the bottom of the tower, while the first method would allow to register also clicks on the top of the tower, if there is no tower on the higher tile.

I guess yet another way would be by creating a region and checking if mouse is inside that region, but I haven't really tried that.

It's a block in the Scene>actors part of palette. You can use it also to point to "last created actor", "last collided actor" or an actor attribute.

Ok, I have found the issue and it was really simple. I needed to add "make self always active" blocks to my actors, because when they were moved they were outside of a screen for part of the frame and it was enough for them to be deactivated :).

Pages: 1 2 3 ... 17