DDR like game

0 favourites
  • 11 posts
From the Asset Store
five golem elements Sprites Sheet.Best for enemy or villain game characters.
  • Hi there :)

    I'm thinking about doing a DDR like game and i'm asking few questions about how to synchronize music and player's action.

    First of all, i thought to split a track into lots of 0.1s

    -Split into 0.1s to use embeded event "Every 0.1s"

    -to keep what is going to do in an array

    [0]=> create new Arrow Up

    [1]=> nothing

    [2]=> create new Arrow Left

    ...

    But i'm not sure that is philosophy of Construct 2...

    So how would you do to make that kind of game?

    I found an example but i can't no more download it.

    Someone have already done this?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • DDR (Dance Dance revolution, a game that plays songs and waits for the player to follow specific inputs scrolling on the screen, made of the keyboard arrows) has a file per song, stating what arrow has to be displayed when. This would be your array. I wouldn't go with the 0.1s segmentation, as if your song isn't on the right beat, it will feel ... not correct.

    Instead, in your array, store 2 datas : the timestamp and the arrow sequence to display.

    Example :

    [0] => (1.3,"T") meaning top arrow at 1.3 second

    [1] => (1.8,"TR") meaning top and right arrow at 1.8 second

    At the start of the song, you wait for the first timestamp to come, display the current arrows (use a bullet behavior to handle their movement), and increment the "current" counter.

    On any given display of an arrow, after displaying/incrementing the counter, you wait for (timestamp(nextArrow)-timestamp(currentArrow))) and call your display function again, until the end of song.

    Then, for the inputs, you would have 2 things :

    • a collision detection between the arrows and a "game over" line, where the arrows can't be clicked anymore if missed
    • on key pressed, checking if a corresponding arrow (top if top was pressed, ...) is near the right place (where it should be on screen when you should click it) and handle the if and else accordingly.
  • Thanks for the answer!

    In fact in programming language (Java, js, ...) i know how to store an object at an index of an array/list or Map/dictionnary but i don t know how to do the same in Construct 2 :(

    Have you an example?

    I should store an array to store 2 (or more) Arrows at the same time.

    I m not as fluent as others programming language for now but i learn a little more each days ^^

  • That's the spirit :)

    If you know arrays in java or js, let me explain it like this in C2.

    Arrays have fixed, given dimensions in C2. You can't just "push" a new element inside, you set a value at a given index X in your array (well, you can push, but it won't change the array size).

    C2 gives you the option for multi dimensional arrays though, up to 3 dimensions. That means that you can have 3 index, X Y and Z.

    In your case, I would use only 2 dimensions.

    X would be the obstacle number (0 for the first arrow, 1 for the second arrow, ...)

    For a given X, we would store at Y=0 the timestamp and at Y=1 the arrows.

    Think of a matrix, with the first column being the timestamp, second one the arrows, a line for each arrow sequence.

    You access a data in an array using the "Array.At(X,Y)" instruction.

    Take a look to the manual on this subject for more infos.

    Last thing, you don't need to store an array to store 2 or more arrows. Just use a single string.

    "T" => top

    "L" => left

    "B" => bottom

    "R" => right

    "TLB" => Top + left + bottom.

    How to analyse this string in C2 ?

    just do 4 test for each string :

    if (tokencount(mySting,"T")>0) => there is a top arrow

    if (tokencount(mySting,"B")>0) => there is a bottom arrow

    ...

  • Oh thanks you so much!

    In fact you can't design a Object like "standard" language with members, methods,... but you store it in a kind of structure where an index represent a member, in fact an array.

    Now i understand what you were meaning by storing an object.

    But i'm still thinking about the design of your solution.

    Your solution seems like that right?

    (the content is given for example)

    [0][0]=0.2 (in second for timestamp)

       [1]="T"

    [1][0]=0.5 (in second for timestamp)

       [1]="LR"

    [2][0]=0.9 (in second for timestamp)

       [1]="T"

    [3][0]=1.2 (in second for timestamp)

       [1]="D"

    I don t understand the need of the index of obstacle and how to know on what index the system is

    Would not it be better to use embeded condition "Every 0.1s" Add 1 to a variable that represent Array index and make an array like :

    [0]=""

    [1]=""

    [2]="T"

    [3]=""

    [4]=""

    [5]="LR"

    [6]=""

    [7]=""

    [8]=""

    [9]="T"

    [10]=""

    [11]=""

    [12]="D"

    ?

    Anyway thanks you for explanations!

    Edit : An array always begin at 0.

    As we say in French : "Les geeks n'ont pas une case en moins ils commencent juste ? partir de 0"

  • Having the song segmented in 0.1s will prove to be a problem if you want to go full like DDR, where the unit is under 0.1s, or some arrows are not on this specific beat.

    Your array will also take mor space in memory, but that is not a problem.

    (in my solution, you started the Y index at 1, it's 0 as in JS btw)

    Your solution doesn't require an index. At t=7s, you just check the 70th row of the array, and use it.

    In my solution, to know what row to check, you need to know what was the last row checked/where we currently are in the array. This index would be set to 0 at the start of the song, and you would add 1 after each display. This index would then let you get the next arrows, ...

    In term of CPU, yours is more intensive. There is a call every 0.1s, where mine takes less CPU (a call only when there are new arrows to display), less memory (for the array), but a timer and a variable (for the index).

    All in all, both solutions are valid. They don't have the same flow, and will raise different problems along the way, but your way is totaly valid too.

  • My solution eats a lot of CPU, you are right ^_^ but i haven't understand yours that's why i ask for explanations and you compare solutions very efficiency!

    I think i miss some kind of condition to implement your solution. If you have to make the same, what condition will you use to "fire" instruction(s)?

    -System. Compare Time

    -System. Compare two values

    -System. Every tick =>seems to be the worst...

    -another?

    I would like to use yours cause you seems to be experienced on C2 <img src="smileys/smiley9.gif" border="0" align="middle" />

  • Ok, I didn't understand that ^^ Let me explain the algorithm then :

    0/ Variables

    CurrentIndex. Initial value : 0. Stores the current index in the array (see below)

    1/ Initialization

    This phase, triggered by the start of layout, fills the array and set the variable to 0. It starts the song. Then, it calls the function "prepareDisplay" in phase 2

    2/ Arrow generation cycle

    This phase is made of 2 functions :

    • prepareDisplay. This function is called with no parameters. It takes the current time of the song, takes the time of the current arrow to display, and waits for the difference, then calls "doDisplay".

    Example, at the start, CurrentIndex = 0. Time of the song = 0. Time of the arrows at the currentIndex (0) of the array is 1,3s. This function will wait 1,3-0 = 1,3s. Then, it will call "doDisplay".

    • doDisplay. This function is called with no parameters. It will take the arrow string ("LT" or anything) at the CurrentIndex in the array, analyse and use it to display new arrows, add 1 to currentIndex, and call "prepareDisplay" again.

    This cycle will make the function prepareDisplay to be called after every time we display the arrows, to wait for the correct next time to work. doDisplay will just do the work, and call again prepareDisplay.

    You will have to add a detection of last arrows of course (end of the array).

    I hope this is more clear. If not, tell me what you don't get ^^

    Btw, this is not really experience with C2, it's mostly how to structure an algorithm. You would do almost the same thing in other languages.

  • Oh my gosh!!! how can i miss that Oo

    You just learn me that there is Function's Object in C2!

    I thought that it was only event oriented programming on sprite, variable,system and i find it just by double clicking... The "Function" Object

    I look a lot of information in manual, made few tutorials and check a lot of example but never see use of that Object...

    I'm sorry about asking you all... You opened my eyes <img src="smileys/smiley36.gif" border="0" align="middle" />

    Anyway i thanks you a lot cause i was missing that feature.

    Oh my gosh i must hide somewhere <img src="smileys/smiley9.gif" border="0" align="middle" />

  • Teclis01

    I did some examples of functions while helping on this forum. I believe this could help you : capx full of comments

    I make use of functions in different ways in the first tutorial of my signature too.

    Yes, having functions is essential if you are somewhat of a programmer. Not necessary for an artist most of the time if the project is simple, but a lot of great things comes from it. You have to understand more concepts though, like UID or else, but it's worth it ^^

    Enjoy your stay in C2 :D

    EDIT : and of course the manual entry !

    Last thing, took me a time to see, but you can rename the function object (F?), making it a lot shorter to write.

  • I already check manual when you mention function

    I duplicated a lot of code and binded instructions (listenner/handler) by a strange way, i ll not do it anymore!

    In fact by using tutorials and few examples, i thought it was the good way... but i mistake. I'm going to check the entire manual before doing errors like that...

    Indeed, i thanks you again for your replies!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)