JavaScript JavaScript Revolution

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Xayphon
    sausage
    FFR Simfile Author
    • Nov 2008
    • 1630

    #16
    Re: JavaScript JavaScript Revolution

    I like the progress you're making, documentation is understandable as well.

    What bugs me still is the fact that everything is still procedural, meaning you have everything written in one .js file. This is fine at the beginning, but if we are aiming to move towards the functionality of the current FFR engine, a more object-oriented approach is needed for a better overview.

    Also question for keyCodes: Does JavaScript also have a getKeyCode() function?
    I'm asking because I just became interested in looking into making an options menu of some sort, with a way to make picking .sm files easier (which is a little bit too much for me right now, I want to get the functionality of having an options button on the interface and have something going on there done first, e.g. change your keybindings before I move to something like that). Let's hope this spontaneous interest persists for some time, provided I don't get lazy while trying to get used to JavaScript in the mean time.

    I also have to check the code again and see if you already have a loop that checks for interface interaction with mouse/keys, and, if not, see where I can actually implement that without fucking up any other procedure within the code.js class.

    Well, actually, would you mind if I try to use your code as a template and see what I can do? I could also try to split code.js into several classes...

    And another question because I'm not really a developer but someone who's interested in coding a little bit and practicing to get better: What program do you use for coding? Do I need some specific compilation program that I need to run in cmd in order to test things out?


    Edit: Yeah, I'm dumb, there are no "classes" in JavaScript like I know them from Java. I'll read up on OOP in JavaScript later, might be a good thing to just leave your code as is right now and check back later, as I'm clearly not obliged to point out errors yet without doing some read-ups beforehand, sorry for that
    Last edited by Xayphon; 11-1-2015, 12:45 PM.

    Comment

    • Trumpet63
      Mostly Ignored
      • Mar 2011
      • 471

      #17
      Re: JavaScript JavaScript Revolution

      Originally posted by Xayphon
      would you mind if I try to use your code as a template and see what I can do?
      If you can look through my 900+ lines of insanity and find something concrete to do something with, please, do whatever you can.

      Originally posted by Xayphon
      Also question for keyCodes: Does JavaScript also have a getKeyCode() function?
      Essentially yes, but currently I'm using an "event listener" to call a function whenever a key is pressed or released (key down and key up). You can see this starting on line 338. I'm using this setup because it was posted on a forum as a solution to the issue that when you hold down a key, typically the OS causes multiple key presses automatically. The alternative would have been keyPressed(), which is a function in processing.js that you would normally use to handle input.

      Processing.js also has mouseClicked(), which is what I would use to do anything mouse-driven. The library has a lot of features that make certain things easier. I would search 'processing.js + whatever' if you're wondering what other stuff it can do.

      Originally posted by Xayphon
      you have everything written in one .js file.
      I know it's awful to look at, and I haven't updated the documentation with stuff from the input update either. I have a plan though. Maybe one or two more features and I plan on breaking the code into a few modules/files/classes... whatever you wanna call them. With JS, I believe the only way to accomplish this (without getting another library) is to load your module files in the main.html, making sure that your central controller module is loaded last. Then, if you defined your modules as functions, you can call those functions in your central module. This is essentially how javascript is able to use a library, because you're calling functions in your central module that exist only in your library.js file.

      Some obvious choices for modules are the .sm file conversion, and the draw notes loop that generates notePos[]... and the controller visualization, which I've now disabled by default because of the massive frame drops ;w;
      2014 October 7th 1:03 AM

      Zageron: Trumpet
      Trumpet63: yes, im here
      Zageron: You have a problem.

      Comment

      • Trumpet63
        Mostly Ignored
        • Mar 2011
        • 471

        #18
        Re: JavaScript JavaScript Revolution

        Originally posted by Xayphon
        What program do you use for coding? Do I need some specific compilation program that I need to run in cmd in order to test things out?
        I use Notepad++, which is basically a text editor that has some friendly features like text coloring, auto-indenting, and stuff like that. Brackets has also been suggested to me, but I haven't gotten used to the layout. Brackets has... many more features than Notepad++ though.

        Do you need cmd or anything complicated? Nope... but step 1 is downloading the game yourself and getting it to run. I don't think anyone has confirmed that they ran this program yet.
        2014 October 7th 1:03 AM

        Zageron: Trumpet
        Trumpet63: yes, im here
        Zageron: You have a problem.

        Comment

        • Xayphon
          sausage
          FFR Simfile Author
          • Nov 2008
          • 1630

          #19
          Re: JavaScript JavaScript Revolution

          I'll try my best to find myself at home with your code, especially when I can test stuff on the fly.

          The processing.js is actually really convenient. I know Java has different event listener libraries for e.g. key and mouse input, but they are seperated in different classes (e.g. KeyListener and MouseListener). We'll see how having these in one class makes things go, it'll be a new experience

          As for the code, no need to rush just yet, it's not even in the stage where multiple people are working at it. It's just you atm. As long as you understand your code, you should be fine. I'll somehow get into it xd

          However, if you are going to separate code.js in several modules/libraries, I'll have you know that it's probably not that easy to separate the code already at this point, as you may have to think ahead quite a bit while making sure everything still works as intended (which is the reason why I suggest that you do it asap). You could also consider making a UML diagram for better organization.

          If I may recommend some brainstormed really basic modules, you could try the following:

          - DrawController.js, a module that handles all the visual drawing snoop and goop like arrows and interface (this module should also be able to react to key, mouse, and more events that you might implement in the future); (gameloop goes here maybe?)
          - FileReader.js, a module for reading and converting .sm files (also has influence on DrawController.js)
          - Game.js, a module for game mechanics (uses converted .sm files from FileReader.js, uses Event.js, and should probably also include audio playing in here)
          - Event.js module for handling key and mouse events
          - Perhaps a class for initiating the game and instantiating all global varriables? (at least the constants, if they are statically accessible if that works in JS)

          edit: I used Notepadd++ for HTML and CSS stuff, atm I use Sublime though. I'll try to get the game to run while I'm at it
          Last edited by Xayphon; 11-1-2015, 02:11 PM.

          Comment

          • Xayphon
            sausage
            FFR Simfile Author
            • Nov 2008
            • 1630

            #20
            Re: JavaScript JavaScript Revolution

            Could you give an example how you wrote a filepath in loadString() and new Audio()? All I get is a grey square so far

            edit: nvm looked into the documentation

            edit2: still getting a grey square (both .sm and .mp3 are in the same directory as code.js)

            Last edited by Xayphon; 11-1-2015, 02:35 PM.

            Comment

            • Trumpet63
              Mostly Ignored
              • Mar 2011
              • 471

              #21
              Re: JavaScript JavaScript Revolution

              Are you running it in Firefox?

              If so... Oh geez. Can you add me on Skype and you can send me those files and I'll try them myself? (I am trumpet.63)

              edit: Can confirm gray box... commence troubleshooting
              Last edited by Trumpet63; 11-1-2015, 03:39 PM.
              2014 October 7th 1:03 AM

              Zageron: Trumpet
              Trumpet63: yes, im here
              Zageron: You have a problem.

              Comment

              • Trumpet63
                Mostly Ignored
                • Mar 2011
                • 471

                #22
                Re: JavaScript JavaScript Revolution

                Status report: Bug Fixed!


                Code:
                .sm file that works fine:
                
                #NOTES:
                     dance-single:
                     Copied from Copied from Copied f:
                     Beginner:
                     2:
                     0.799,0.797,1.000,0.420,0.493:  // measure 1
                ...
                
                .sm file that causes an error:
                
                #NOTES:
                     dance-single:
                     :
                     Hard:
                     10:
                     1.000,1.000,1.000,1.000,1.000:
                  // measure 1
                ...
                It was returning that there was a note at position 13 (which is where that "1" is on the last line above), meaning it was asking to store a note for receptor #13, which of course didn't exist, hence the error.



                The bug was hard to find but easy to fix. Just one if-statement.

                EDIT: Thank you for finding the bug Xayphon! This is why I need testers :3
                Last edited by Trumpet63; 11-1-2015, 04:02 PM.
                2014 October 7th 1:03 AM

                Zageron: Trumpet
                Trumpet63: yes, im here
                Zageron: You have a problem.

                Comment

                • PrawnSkunk
                  Administrator
                  FFR Simfile Author
                  FFR Administrator
                  • Dec 2007
                  • 3907

                  #23
                  Re: JavaScript JavaScript Revolution

                  Thanks Trumpet for letting me reference your .sm parser for my processing class project! It definitely made the process a lot easier

                  (8-key rhythm game that converts doubles charts to be playable on a technomotion dancepad or keyboard numpad)




                  Last edited by PrawnSkunk; 12-15-2015, 12:30 AM.

                  Comment

                  • Trumpet63
                    Mostly Ignored
                    • Mar 2011
                    • 471

                    #24
                    Re: JavaScript JavaScript Revolution

                    Huge thanks to Llyair, the .sm parse code has been refactored and now can read any bpm changes, not just those that occur at the start of a measure. Documentation is hugely out of date now.

                    And hey, sorry I've been gone so long, I'm trying to transfer to a university right now!
                    2014 October 7th 1:03 AM

                    Zageron: Trumpet
                    Trumpet63: yes, im here
                    Zageron: You have a problem.

                    Comment

                    Working...