yahiko

Members
  • Content count

    69
  • Joined

  • Last visited

About yahiko

  • Rank
    Advanced Member

Contact Methods

  • Twitter
    YahikoUzumaki2

Recent Profile Visitors

760 profile views
  1. Let us assume C the center of your black circle, and P the center of the player. You need first to compute the vector CP from C to P. CP = P - C Given this vector CP, you need to normalize it to a unit vector, CPu by divinding each coordinate by its length. Then, you can the compute the angle alpha of this vector with the help of the JavaScript built-in trigonometric functions Math.acos() and Math.asin() or more simply with Math.atan2(CP.y, CP.x) which doesn't even require to normalize CP before. You can finally assign your sprite's rotation attribute this angle alpha, with some constant given the initial orientation of your sprite.
  2. VS Code + TypeScript + Phaser is a good match for me which can be expressed as lightweight productivity.
  3. Maybe a stupiid advice, but have you tried to manually clear the cache of Firefox?
  4. No answer, so I have to assume it is a no... ^^
  5. You can even generate the tsconfig.json with this command: tsc --init Also, TypeScript 2.0 RC is quite stable and it is not a big risk to use it now: npm install -g typescript@rc
  6. Hi, I am wondering if there is a way to enable physics (P2 for instance) on something different than a sprite: game.physics.p2.enable(myObject); where myObject is not a sprite, but a custom object of mine. Thanks!
  7. Thanks, I will have a look at this proposal.
  8. Hi everyone! Here are some news about my little project which can be tested here: Clash of the Daemons. We can now move and attack at the same time. More generally, the input handling has been improved with implementation of multiple commands assignement for a keystroke as well as a delay before repeat. We can go back to the title screen after the game over. Behaviors can now be assembled together. High-level behaviors have been redesigned, especially ranged attack and hit-and-run. A new behavior, sneak attack, has been implemented (Fig. 2). A character (pawn) can have a set of weapons (inventory). Current weapons are claw (melee) and fireballs (ranged). Only one weapon can be active at a time. Each weapon has a charging time (time needed before activation), an activation time (time the weapon is active as well as its effects) and a cooldown time (time during which the weapon is unsusable). Key mapping has been changed accordingly. CTRL to attack, and TAB to switch to the next weapon. Debugging mode has been improved. These following informations can be displayed: FPS, grid, velocity vector, obstacle detector, hitbox, collisions, simplified sprites (Fig. 3). Improved the build process with the automation of graphical assets compilation (mainly the spritesheet). Title screen has been updated and improved a little bit (Fig 1.) Bug fixes: Attack animations run to their last frame. A memory leak in the AI module has been fixed. When the player loses a life, the HP bar now updates accordingly. Monsters will not be spawned at the same location of another game object anymore. Fig. 1: Title screen Fig. 2: Sneak attack behavior Fig. 3: Displaying debug mode informations There is a lot of room for improvements (and bug fixes! ^_^) of course. Still, if there is anyone serious enough interested in this project, for improving its game design, gameplay, graphics, sounds, musics, background story, programming also, feel free to contact me. Best, Yahiko
  9. Hi Yahiko,

    we are going to do a christmas version of the game and I may take a look to the AI even though the customer didn't require that.

    Which were the most obvious shortages of the AI you saw?

    By the way, have you developed any games?

  10. Thanks for your comment. Well I would say that its first feature is to be in native TypeScript and do not use interface. It is very simple and has no ambition unless being useful for me and maybe for some other people. About the terminology issue, I would be interested if you do not mind giving me a link about the spec proposal using the term Observables. I have not used pub/sub since in my mind it is a little bit different (with a message broker iirc). In the future, this library should implement 2-way data binding, that is the plan indeed, but for the moment, it is just an addEventListener()-like library, DOM independent. Thanks for the feedback.
  11. Nice game, very enjoyable ;-) Maybe a little bit easy to trick the AI at some moments, but this does not affect the fun factor. Great work!
  12. Hi, I have implemented a simple Observer Pattern library in TypeScript/JavaScript which does not require inheritance. I have called it Paon (French name for a bird with many "eyes" on its feathers). It is available in my GitHub and in npm. Any feedback would be greatly appreciated. Paon An Observer Pattern Component in TypeScript/JavaScript. No dependencies. No inheritance is required. Observable is just a component inside an object. Observers are just functions. Installation npm install paon To compile the TypeScript source to JavaScript, you would need to install the TypeScript compiler: npm install -g typescript To generate the minified JavaScript version when building, you would need to install uglifyjs: npm install -g uglifyjs Build Resulting files are created in the dist/ folder. Complete build (compilation and minification): npm run build Simple compilation (no minification): npm run compile Usage All constants, interfaces, classes and functions are accessible inside the Paon namespace. Simple example Here is a simple example where we add an observable component inside a class Subject: /// <reference path="paon.d.ts" /> class Subject { private name: string; observable: Paon.Observable; // Observer Pattern component constructor(name: string) { this.name = name; this.observable = new Paon.Observable(); // Instanciation/Initialization } changeName(name: string): string { this.name = name; this.observable.notifyObservers("nameChanged"); // A message is sent to observers return this.name; } } function onNameChanged() { alert("Name has changed"); } let subject = new Subject("Penelope"); subject.observable.addObserver("nameChanged", onNameChanged); // Function onNameChanged() subscribes to subject's messages "nameChanged" subject.changeName("Melissa"); // An alert popup appears: "Name has changed" Above, in the class Subject, the method changeName() will send a "nameChanged" message to the instance's observers. After the instanciation of Subject, the function onNameChanged() subscribes to subject's messages "nameChanged". Therefore, when changeName() is called, an alert popup appears. As we can see, with such a pattern, no inheritance with extends or implements is required. Just simple composition. Example with extra data We can send extra data to observers as we can see below: /// <reference path="paon.d.ts" /> class Subject { private name: string; observable: Paon.Observable; // Observer Pattern component constructor(name: string) { this.name = name; this.observable = new Paon.Observable(); // Instanciation/Initialization } changeName(name: string): string { this.name = name; this.observable.notifyObservers("nameChanged", { data: name }); // A message with extra data is sent to observers return this.name; } } function onNameChanged(msg: { data: string }) { alert("Name has changed into " + msg.data); } let subject = new Subject("Penelope"); subject.observable.addObserver("nameChanged", onNameChanged); // Function onNameChanged() subscribes to subject's messages "nameChanged" subject.changeName("Melissa"); // An alert popup appears: "Name has changed into Melissa" The parameter msg in function onNameChanged() contains the extra data we have sent via method changeName(). Here, this is an object with a property data, but this could be anything. Module Importation This library can also be imported as a module with the import statement: import Paon from "./paon"; // Declaration file .d.ts location class Subject { private name: string; observable: Paon.Observable; // Observer Pattern component constructor(name: string) { this.name = name; this.observable = new Paon.Observable(); // Instanciation/Initialization } changeName(name: string): string { this.name = name; this.observable.notifyObservers("nameChanged", { data: name }); // A message with extra data is sent to observers return this.name; } } function onNameChanged(msg: { data: string }) { alert("Name has changed into " + msg.data); } let subject = new Subject("Penelope"); subject.observable.addObserver("nameChanged", onNameChanged); // Function onNameChanged() subscribes to subject's messages "nameChanged" subject.changeName("Melissa"); // An alert popup appears: "Name has changed into Melissa" Only the import statement differs from previous examples. Otherwise, the code is the same. API Documentation Add an observer to a type of message (similar to the DOM function addEventListener()): Paon.Observable.addObserver(type: string, observer: Observer): Observer; Remove an observer from a type of message (similar to the DOM function removeEventListener()): Paon.Observable.removeObserver(type: string, observer: Observer): void; Remove all observers from a type of message: Paon.Observable.removeObserversType(type: string): void; Send a message to observers (similar to the DOM function dispatchEvent()): Paon.Observable.notifyObservers(type: string, msg?: any): void; Contributors yahiko Licence MIT
  13. Link : http://yahiko.developpez.com/apps/ClashDaemons/ Controls: Arrow keys to move CTRL for melee attack SHIFT for ranged attack This is a hack 'n slash based on a prototype for an AI implementation of behavior trees, which is the main reason of this project. Sprites of monsters come from OpenGameArt.org. The title screen and the HUD were made by myself. Features implemented so far: 2D circle based collisions AI (cf. below) Pathfinding (not enabled for now) Respawn of monsters AI behaviors implemented so far: : Melee attack : Ranged attack : Hit and run : Just wandering Technologies: Written in TypeScript Powered by Phaser Framework If anyone serious enough is interested to improve this game (game design, game play, graphics, optimizations), feel free to contact me.
  14. Hi, I don't really know Babylon or the physics engine used in your example, but I am wondering wether time step needs conversion as well in order to make things work properly. The constant of gravity is an acceleration expressed in a distance unit divided by the square of a time step unit. Usually, in Europe the distance unit is in meter and time step in second, but in video games, I often have to consider frame (or tick) as a time step. Maybe you might have a look at your conversions with that in mind. This could solve your understanding issue.
  15. I am wondering if I could use the reset() method of a QuadTree object the same way as the clear() method. After checking the source code, it seems reset() would be faster since there is no reccursion, only setting arrays length to 0. But, I am still unsure it has no drawback compared to the standard clear() method. Anyone has some insight about it? Thanks!