Skip to content

Instantly share code, notes, and snippets.

View shohan4556's full-sized avatar
💻
Making things that does not Exists !!

Shohanur Rahaman shohan4556

💻
Making things that does not Exists !!
View GitHub Profile
import { SceneObject } from "types";
const DEFAULT_ZOOM = 0.01;
const scrollMap = (scene: SceneObject, pointer: Phaser.Input.Pointer, zoom: number) => {
zoom = Phaser.Math.Clamp(Phaser.Math.RoundTo(zoom, -3), 0.01, 1);
if (scene.globalPosition) {
scene.cameras.main.centerOn(scene.globalPosition.x, scene.globalPosition.y);
scene.cameras.main.zoomTo(zoom, 0);
// necessary modules
const {
Engine,
Render,
World,
Body,
Bodies,
Mouse,
MouseConstraint,
Constraint,
function ONMOInit() {
var isUnload = false;
onmoHtmlGame.init({
unload: function () {
console.log("#unload");
game.destroy();
onmoHtmlGame.sendEvent(OnmoHtmlGame.EVENTS.UNLOADED);
isUnload = true;
//box3
const box3 = this.add.container(startX / 2 - 100, 350).setDepth(20);
square = this.add.sprite(0, 0, "square").setOrigin(0.5).setScale(0.5);
number = this.add.text(40, -50, 3, { color: 0xffff });
item = this.add.image(0, 0, this.levelData[index].boxs[0]).setOrigin(0.5);
box3.add(square);
box3.add(number);
box3.add(item);
box3.setSize(128, 128);
@shohan4556
shohan4556 / highscore.js
Created December 19, 2021 13:21
simple highscore
// save score for the first time
if (localStorage.hasOwnProperty("score") == false) {
localStorage.setItem("score", this.SCORE);
} else {
const savedScore = localStorage.getItem("score");
if (this.SCORE > savedScore) {
localStorage.setItem("score", this.SCORE);
}
}
{
"tilesets": [
{
"columns": 1,
"firstgid": 1,
"image": "tile64x64.png",
"imageheight": 64,
"imagewidth": 64,
"margin": 0,
"name": "tile64x64",
@shohan4556
shohan4556 / check overlap without physics
Created December 5, 2021 12:25
check overlap without physics
const position = getRelativePositionToParcel(parcel, worldPosition);
console.log('relativePosition', position);
if (parcel && !isOverlap(parcel, position)) {
}
function getRelativePositionToParcel({ bounds }, pxPosition) {
// Return position top_left position in InstallationGrid
return {
x: (pxPosition.x - bounds.x) / GOTCHI,
y: (pxPosition.y - bounds.y) / GOTCHI,
function create ()
{
var polygon = new Phaser.Geom.Polygon([
400, 100,
200, 278,
340, 430,
650, 80
]);
var graphics = this.add.graphics({ x: 0, y: 0 });
generateTerrain(graphics, mountainStart) {
// array to store slope points
let slopePoints = [];
let slopesCount = 0;
let slopeStart = new Phaser.Math.Vector2(0, mountainStart.y);
let slopeLength = Phaser.Math.Between(
this.terrainConfig.slopeLength[0],
this.terrainConfig.slopeLength[1]
);
@shohan4556
shohan4556 / object-outline-and-dimensions-opencv.py
Created January 16, 2020 10:42 — forked from benmarwick/object-outline-and-dimensions-opencv.py
Python 3 script to take live video, detect the largest object, trace an outline (contour) and measure linear dimensions, using OpenCV
# in a terminal
# python -m pip install --user opencv-contrib-python numpy scipy matplotlib ipython jupyter pandas sympy nose
import cv2
import pandas as pd
import numpy as np
import imutils
from scipy.spatial import distance as dist
from imutils import perspective