11import { mat4 , vec2 , vec3 } from "gl-matrix" ;
22import type { AnimationIndex } from "../sprites" ;
33
4- export const MAX_ENTITIES = 10_000 ;
4+ export const MAX_ENTITIES = 8_000 ;
55
66export const createState = ( ) => {
77 const objectMatrices = new Float32Array ( MAX_ENTITIES * 16 ) ;
@@ -17,7 +17,9 @@ export const createState = () => {
1717 return {
1818 time : 0 ,
1919 pointer : { x : 0.5 , y : 0.5 , down : false } ,
20- zoom : 800 ,
20+ zoom : 0.9 ,
21+
22+ worldSize : [ 1 , 1 ] as vec2 ,
2123
2224 camera : { eye : [ 0 , 4 , 4 ] as vec3 } ,
2325 viewMatrix,
@@ -74,6 +76,7 @@ export type State = ReturnType<typeof createState>;
7476export const setInitialState = (
7577 state : State ,
7678 animationIndex : AnimationIndex ,
79+ entityCount : number ,
7780) => {
7881 const accessoriesIndex1 = [
7982 animationIndex . cap ,
@@ -85,8 +88,7 @@ export const setInitialState = (
8588 ] ;
8689 const accessoriesIndex2 = [ animationIndex . glasses , animationIndex . sunglasses ] ;
8790
88- const N = 400 ;
89- for ( let i = N ; i -- ; ) {
91+ for ( let i = entityCount ; i -- ; ) {
9092 const accessories : number [ ] = [ ] ;
9193
9294 const a1 =
@@ -102,7 +104,10 @@ export const setInitialState = (
102104 if ( a2 !== undefined ) accessories . push ( a2 ) ;
103105
104106 state . runners . push ( {
105- position : [ ( Math . random ( ) * 2 - 1 ) * 10 , ( Math . random ( ) * 2 - 1 ) * 10 ] ,
107+ position : [
108+ ( Math . random ( ) * 2 - 1 ) * 20 - 40 ,
109+ ( Math . random ( ) * 2 - 1 ) * 20 ,
110+ ] ,
106111 velocity : [ 0 , 0 ] ,
107112 animationIndex : animationIndex . walk ,
108113 animationOffset : Math . floor ( Math . random ( ) * 10 ) ,
0 commit comments