Braus's Recent Forum Activity

  • You can't do this - animationsList&"_points" - with variable names.

    You'll need a temporary variable s and a bunch of events like:

    If CategoryNumber=1 Set s to Category1_points

    If CategoryNumber=2 Set s to Category2_points

    Or you can store your lists of points in a dictionary, under keys "Category1_points", "Category2_points" and do this:

    s=PointsDictionary.Get("Category" & CategoryNumber & "_points")

    Add tokenat(s, Sprite1.animationFrame, ",") to totalPoints

    I think I understood your suggestion. I will give it a try and after that, I will return here to leave a feedback.

    Thanks

  • Sorry about the delay.

    I just would like to know if I also can use the token to store the points, associanting the animation frame to the points order in the variable categoryX_points. If so, could you please check the example below and tell me where I need to include the animation in the tokenat expression to get the frame that is showing on the screen? Please, confirm if the example is correct.

    Something like this:

    animationList = category1

    anima1_points = 5,2,3,1,2,4,1,2,3,2

    add tokenat(animationsList&"_points", floor(tokencount(animationsList.animationFrame, ","))), ",")to totalPoints

  • >

    > Simple points. For example: frame 1 worth 3 points, frame 2 worth 1 point, 3 worth 7 points...

    >

    Ok, but you will have at least 100-200 different frames. How your game will know how much points each frame worth? Where will you get this information from?

    May I could use arrays to store these points, one for each animation. What do you think about this? Do you know a more practical solution?

    And about the repetition issue? What can I do to avoid the animation and frame (image) repetition?

  • Hi dop2000

    Thanks for replying.

    2. You need to decide how you want to store these lists of categories/animations - you can read them from a text file (csv, xml etc) or load as JSON into an array or dictionary.

    Or you can simply create 6 text variables:

    category1 = "anima1,anima3,anima5"

    category2 = "anima2,anima4"

    ...

    I will use simple variables for this 1st test but I intend to use a DB to store and load informations.

    [quote:2m2n2ohh]3. When player selects a category, you can choose a random animation from a comma-separated string of animations using this expression:

    animationsList = category3 // for example

    animationName = tokenat(animationsList, floor(random(tokencount(animationsList, ","))), ",")

    Is this animation list will be filled by the string variable "category3" and the tokencount will be separate this information and randomize them? Is that correct?

    [quote:2m2n2ohh]

    Then set this animation to a sprite and choose a random frame:

    Sprite1 set animation to animationName

    Sprite1 set frame to floor(random(Sprite1.AnimationFrameCount))

    Repeat the same steps for the seconds sprite.

    I think I got it (but I am not sure) but anyway, I don't know how to avoid the animation/frame repetition (frames because a same frames could be found in more than an animation)

    [quote:2m2n2ohh]4. How do you assign a value to selected frame I don't know, you need to give more information about these values. What are they? Are they different for each frame? Where are you planning to get these values from?

    Simple points. For example: frame 1 worth 3 points, frame 2 worth 1 point, 3 worth 7 points...

  • 1) I have two sprites (sprite1 and sprite2) with the same animations (10 in total) with different amount of frames each:

    anima1 = pic1, pic2, pic3, pic4, pic5, pic6, pic7, pic8, pic9, pic10

    anima2 = pic3, pic5, pic7, pic8, pic9, pic10, pic12, pic15, pic16, pic17, pic18, pic19, pic20

    anima3 = pic1, pic3, pic5, pic7, pic9, pic11, pic13, pic15, pic17, pic19, pic21

    .

    .

    .

    anima10 = pic2, pic3, pic4, pic12, pic13, pic14

    2) The game will have 6 categories and each category will have references for some animations of the sprites I have cited:

    category1 = anima1, anima3, anima5

    category2 = anima2, anima4

    category3 = anima1, anima2, anima3, anima4, anima5, anima6, anima9, anima10

    .

    .

    category6 = anima1, anima2, anima5, anima6

    3) The player will choose between numbers 1 and 6 and the system needs to get the categories of the respective group and show a randomly frame of a randomly animation of the sprite1 and a different randomly frame of a randomly animation of the sprite2:

    Player choose number 3

    sprite1 = anima2 / pic4

    sprite2 = anima10 / pic14

    4) The player now needs to chose one of these two pictures and each will have a different value that I need to add to a score that represents the animation (each frame of each animation has a different value):

    Player choose pic14

    Add 5 to the scoreAnima10

    The last process (4) needs to repeat 10 times.

    At the end, I need to show the total score and what animation wins. If we have a tie, the system needs to show images of the respective animations to tie up.

    I need to understand what I need to do for each stage of the script.

  • Thank you!

  • Could you please share a simple example in CAPX?

  • "startGame = wallclocktime" should only be executed once on start of the game (level), not on every pressed key.

    It happens once when the user press the 1st key but I moved this command to the start of the layout.

    [quote:3ijb3v58]This formula is also incorrect:

    speedPerSecond= (totalHits) / (startGame)

    Change it to:

    speedPerSecond= (totalHits) / (wallclocktime-startGame)

    I fixed the formula but the time continues to increase as the keys are pressed.

  • I think I am doing something wrong. The value is increasing instead of showing the typing speed

    A summary of my code:

    On any key pressed: call checkKey()
                        call calculateTime()
                        controllStartGame = 0 : controllStartGame = 1
                                                startGame = wallclocktime
    on calculateTime: System keyOrder isTrue: add 1 to totalHits
    
    on checkKey:  speedPerSecond= (totalHits) / (startGame)
                  speedPerMinute=speedPerSecond*60
                  textObject : set text to round(speedPerMinute * 100) / 100[/code:19tt8cxv]
  • Thank you

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You need to save the time when typing starts in a variable: gameStart=time

    When the last correct character is typed, you can calculate the speed:

    speed= (number of characters) / (time-gameStart)

    Multiply it by 60 to get characters per minute.

    If you need to count words per minute, this might be a little more complex.

    Hi

    Thanks for answering. I just want to count the characters.

    So I have to register the initial time and count all the characters the user typed at the same time that I need to divide it per initial time? Wiil I get this value in real time (as the user type the characters?) I read something about PPM but I don't know how to implement it.

  • I am trying to create a typing simulator and I need to calculate the speed of the typing and I don't know how I can do this.

Braus's avatar

Braus

Member since 17 Jul, 2015

None one is following Braus yet!

Trophy Case

  • 9-Year Club
  • Email Verified

Progress

10/44
How to earn trophies