Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure backgrounds to levels #90

Open
14 tasks
niccokunzmann opened this issue Feb 12, 2016 · 16 comments
Open
14 tasks

Restructure backgrounds to levels #90

niccokunzmann opened this issue Feb 12, 2016 · 16 comments

Comments

@niccokunzmann
Copy link
Member

Each level has

  • backgrounds
  • obstacles

In a level.js file:

  • each level should be an own object

Add methods:

  • Level.show()
  • Level.start()
  • Level.stop()
  • Level.hide()
  • Level.getBackgrounds()
  • Level.getObstacles()
  • Level.getName()
  • Level.score() - return the score that should be displayed.

Add functions:

  • getAllLevels()
  • newLevel(name, [backgrounds], [obstacles])
  • createAlllevelObjects() - is called one at the start of the game, uses newLevel()
  • setCurrentLevel(name)
  • getCurrentLevel() - the currently selected level

The idea is to create good code. This is the draft and it may need to change once started.

Comment if you would like to work on this.

@SilentFlame
Copy link
Contributor

@niccokunzmann
I can give a try.

@niccokunzmann
Copy link
Member Author

@SilentFlame Sure, you are welcome. You do not have to do everything at once. You can split it up into several pull-requests.

@hkveeranki
Copy link
Contributor

i am interested in working on this. I have a doubt . In order to add this we need to change some part of code in otherfiles as well right. like loading backgrounds and stuff

@niccokunzmann
Copy link
Member Author

Yes. It is a refactoring that touches a lot. We will gain in the long run. You can start it by creating the object with the interface mentioned above. The methods can be filled step by step and it does not need to be you who does everything.

Some reading to the why: https://en.wikipedia.org/wiki/Technical_debt

@hkveeranki
Copy link
Contributor

hkveeranki commented Jul 30, 2016

@niccokunzmann These levels corresponds to game levels right ?

Also

Level.show()
Level.start()
Level.stop()
Level.hide()

What does they do?
I assume show and hides shows and hides the obstacles and backgrounds. Am I right? What about the other two ?

@niccokunzmann
Copy link
Member Author

In the beginning, we can choose levels: Gotham or desert. Show and hide allow to show these levels. start() and stop() are used for playing them.

@niccokunzmann
Copy link
Member Author

Now that I read your code, I know more what I am aiming to.

Currently, the data (not functionality) for a level is spread across these files:

If we can put this all together in one file, we can add new levels more easily.

var level_specifications = [
    {
        "name" : "Desert",
        "backgrounds" : [
            {
                "layer" : "DayAndNight",
                "velocity" : -20
            },
            {
                "layer" : "background",
                "velocity" : -7
            },
            {
                "layer" : "SunAndMoon",
                "velocity" : 1
            },
            {
                "layer" : "sky",
                "velocity" : ???
            }
        ],
        "obstacles" : [
            {
                "layer" : "cactus",
                "velocity" : -7
            }
        ]
    },
    {
        "name" : Gotham",
        "backgrounds" : [
            {
                "layer" : "Gotham",
                "velocity" : -7
            }
        ],
        "obstacles" : [
            {
                "layer" : "Gotham_obstacles",
                "velocity" : -7
            }
        ]
    }
]

character_specifications = [
    "bird", // we can add more parameters like gravity and flap speed
    "bat",
    "alien",
    "flappydino",
    "helicopter"
] 

@niccokunzmann
Copy link
Member Author

niccokunzmann commented Aug 1, 2016

In future, if it is possible to add a new background to the svg file and then edit this specification and that is all, this is a huge relief and gives us a lot of freedom in the functionality.
It would also make it easier to split up the svg file into several smaller svg files without touching this specification.

@hkveeranki
Copy link
Contributor

@niccokunzmann I made a change to the level specification thing to make it look some what clear. Please Have a look and comment on the status.

@niccokunzmann
Copy link
Member Author

@harry-7 I commented. I hope my absence does not discourage you. I was working on this: https://www.youtube.com/watch?v=38JN2JdNnMY&feature=youtu.be

@hkveeranki
Copy link
Contributor

@niccokunzmann Yeah never mind. The video was cool :). Even though I did not understand it completely. It was cool.

@hkveeranki
Copy link
Contributor

@niccokunzmann In the above checklist I think we need to couple of changes.

  • getAllLevels()

This is not needed anymore .

And except level.start() and level.stop() all the remaining are implemented may be you can check them. What do you say ?

@niccokunzmann
Copy link
Member Author

niccokunzmann commented Aug 5, 2016

I will check them as soon as they are used in the program and replaced the old functionality. This is as soon as the functionality is not in these files any more.

@hkveeranki
Copy link
Contributor

hey @niccokunzmann . Can I take this up ? Or is the GCI thing still going on ?

@niccokunzmann
Copy link
Member Author

@harry-7 sure you can take this up, regardless of GCI going on or not.

@hkveeranki
Copy link
Contributor

@niccokunzmann what is the idea behind level.start() and level.stop() methods? as in what work needs to be done by them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants