Skip to content

Instantly share code, notes, and snippets.

Avatar

Limes2018 flushpot1125

View GitHub Profile
View gsap_camera_motion2.ts
import { UniversalCamera } from "@babylonjs/core";
import {gsap} from "gsap";
import {fromScene} from "../tools";
export default class CameraComponent extends UniversalCamera {
@fromScene("cube")
private _cube : Mesh;
public onStart(): void {
var tl = gsap.timeline({repeat: 2, repeatDelay: 1});
View gsap_cameramotion_test.ts
import { UniversalCamera, Mesh } from "@babylonjs/core";
import {gsap } from "gsap";
import {fromScene} from "../tools";
export default class CameraComponent extends UniversalCamera {
@fromScene("node-0_primitive13")
private _wall13 : Mesh;
public onStart(): void {
View bjseditor_pingpong_index.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Babylon.js Generated Template</title>
<script src="./dist/bundle.js" type="text/javascript"></script>
<!-- <script src="./node_modules/cannon/build/cannon.js" type="text/javascript"></script> -->
<script src="./cannon.js" type="text/javascript"></script>
View HUD_showMessages.ts
let messages;
export default class HUD extends Node {
public onStart(): void {
messages = new TextBlock();
messages.name = "game messages";
messages.textHorizontalAlignment = TextBlock.HORIZONTAL_ALIGNMENT_CENTER;
messages.fontSize = "60px";
messages.color = "white";
View HUD_removeHearts.ts
export function removeHeart(){
// hearts[heartcnt-1].dispose();
hearts[heartcnt-1].alpha=0;
heartcnt--;
if(heartcnt !=0){
StateChange(State.LOSTHEART);//ハートが無くなったらstateを変更
}
if(heartcnt ==0){
StateChange(State.GAMEOVER);
showMessages("You lose. Reload to play again");
View ball_removeHeart.ts
public onUpdate(): void {
if( (this.position.x <-28)&& (callOnceRemoveHeartsFlag==false)){
removeHeart();
callOnceRemoveHeartsFlag=true;
}
}
View block_call_addScore.ts
import {addScore} from "./HUD";
//part of full code
export default class block extends Mesh {
public onUpdate(): void {
if ((this.intersectsMesh(this._ball)) && this.callFlag== false){
this.callFlag=true;
this.blockDispose();
}
}
View HUD_addscore.ts
export function addScore(): void{
colliedcnt++;
blockCountMessages.text="blocks"+ colliedcnt+"/8";
if(colliedcnt == 8){
StateChange(State.GAMECLEAR);
showMessages("Congratulations!! CLEAR!!Reload to play again");
}
}
View HUD_text_image.ts
import {AdvancedDynamicTexture,TextBlock,StackPanel,Image} from "@babylonjs/gui";
public onStart(): void {
const playerUI = AdvancedDynamicTexture.CreateFullscreenUI("UI");
const stackPanel = new StackPanel();
stackPanel.height = "100%";
stackPanel.width = "100%";
stackPanel.top = "14px";
stackPanel.verticalAlignment = 0;
playerUI.addControl(stackPanel);
View 2dgame_index.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ping pong game</title>
<script src="./dist/bundle.js" type="text/javascript"></script>
<script src="./node_modules/cannon/build/cannon.js" type="text/javascript"></script>
You can’t perform that action at this time.