frankarendpoth / frankarendpoth.github.io Goto Github PK
View Code? Open in Web Editor NEWFrank Poth's Github page
License: MIT License
Frank Poth's Github page
License: MIT License
Your Google site verification code is completely visible and easily accessed by any person viewing this repository. This is a security flaw, and you may wish to fix it.
Of course it is up to you what you do with your verification code, but I would highly suggest taking it off of the repo.
Hi,
thank you for the Tutorial on the Platformer Game (https://github.com/frankarendpoth/frankarendpoth.github.io/tree/master/content/pop-vlog/javascript/2018/006-rabbit-trap). I really enjoyed watching it. While implementing an own version of it, I recognized an issue with how you implement the "class inheritance".
The way you do it is the following:
Superclass = function(){
//Definition of Superclass attributes
}
Superclass.prototype = {
//Definition of Superclass methods
}
Subclass = function(){
Superclass.call(this);
//Definition of Subclass attributes
}
Subclass.prototype = {
//Definition of Subclass methods
}
Object.assign(Subclass.prototype, Superclass.prototype);
Subclass.prototype.constructor = Subclass;
This seems to work for your approach, but as soon as you want to override methods, your implementation leads to always calling the superclass' method instead of the subclass one (Similar to the constructor, that you also had to fix after the assignment).
A nicer way of implementing your approach, and also have the correct overriding behavior would be to turn around the assignment and e.g. use the following instead:
Superclass = function(){
//Definition of Superclass attributes
}
Superclass.prototype = {
//Definition of Superclass methods
}
Subclass = function(){
Superclass.call(this);
//Definition of Subclass attributes
}
Subclass.prototype = Object.assign(Object.create(Superclass.prototype), {
//Definition of Subclass methods
});
That way, the subclass' prototype methods correctly overwrite the Superclass once. Method overriding works as intended. No need to fix constructors.
Best,
Daniel
I think update and render methods are inverted in the Engine constructor.
Shouldn't it be const Engine = function(time_step, render, update) {
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.