Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

define x_position depending on 2 variable (& break loop)

Hi,
I have another problem. I hope I'm not bothering you!

So, I have an rectangle on a sketchpad. The sketchpad is a loop and the x_position of the rectangle depends on the iteration of the loop. So for the first iteration through the loop it is -350, for the second iteration it is -300 and so on.

Question 1: I want to make it possible for the participant to end the loop when s/he feels that the rectangle is at the right position (and save that position in a variable). Each individual iteration through the loop is ended with a keypress (and then the next iteration starts), i.e. the duration of the sketchpad is keypress. But how can I end the loop and save the position?

Question 2: In the next loop the participants can define the width of the rectangle. With each iteration of the loop the width gets bigger. Here I also have to have the possiblity for the participants to stop the loop if they feel it is the correct width. But my question for this is primarily another one: The x_position depends on the position of the previous loop. I.E. if the participant feels that 300 is a good position it should be x=300. That is no problem, but now I increase the with and it has to add with on both sides of the rectangle equally. So in order to achieve that (because width automatically is added on the right) I add 2pixel of with and move the rectangle one px to the left at the same time. So that it looks like the width was added on the left and on the right. But: I add 2 px in the first iteration of the loop, another 2 in the second iteration (so 4 in total) and so on, so the x-position depends on 2 variables: The position that was defined in the first loop and the iteration of the second loop. So if the x-position was defined as 300 in the first loop and it is the second iteration of the second loop it should be 300-2. So it depends on two variables: The variable of the first loop x_pos and the variable of the second loop x_pos_change. How can I combine those 2 variables?
I tried with an inline-script in which I wrote:
x_pos_new = exp.get(var.x_pos + var.x_pos_change)
But this doesn't work as it tells my x_pos_new does not exist when I define the x-position as x=[x_pos_new]

Comments

  • Hi Pia,

    Question 1:

    When waiting for a keypress allow two different keys. One (say space) will flip the sketchpad and show the next reactangles. The other (let's say return will also make the sketchpad disappear, but on top of that, it will break the loop. How to implement it depends on how you implemented the other parts of your experiment.

    Question 2:

    I think what you meant to do, is exp.set() not exp.get(). So try this: exp.set('x_pos_new',var.x_pos + var.x_pos_change).
    Maybe it would be easier if you save the middle x coordinate instead of the top left point. Then you don't have to do these funny manual things with adding things to the left and the right. Once you have the middle_x, you can draw a rectangle easily by canvas.rect(x-0.5*width,y,width,height)

    Eduard

    Buy Me A Coffee

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games