P5.JS 3d how to pre-rendering - javascript

My project is to complete our Computer Science Final Project. Our teacher forced us to use the P5 framework to write games on the web for the Final Project. I don't want to write a 2D game because it is so easy.
So I tried to use P5.js to imitate Minecraft to write a game as my Final Project (our teacher said that I can imitate the existing game modes and ideas, just to ensure that the code is written by myself.)
Because the single-thread performance of P5.js is too poor, and the block does not support multiple textures, I can only use a plane to draw the block, but this causes my FPS to be seriously reduced. Drawing 10 * 10 blocks will reduce the FPS to 80 about.
I want to ask whether p5.js can pre-render frames, or how to directly operate webgl?
I can only use p5.js because our teacher does not allow our final project to use other frameworks to write web games.
The FPS in the following display is the number of frames per second of the draw function of p5. Since P5 can only draw graphics in Draw, and this is a serial drawing, when the drawing function takes too long, it will reduce the FPS. I The Minecraft to be imitated may require a field of view of at least 50x50-80x80 blocks, which is not a block underground.
If I have 9x9 blocks, I will get 144FPS:
If I have 20x20 I will get 88FPS:

Related

What should I use to create a 2D game with JS (runner game)?

I'm a frontend developer and now I have a task to create a game.
Example is ⇾ http://redcarpetrampage.com/
The player should run via two buttons, only if event is "onkeyup" (or maybe "tap" on mobile).
The logic of all game is 95% like in example. Game hero should run, jump and collect something and in the end will get some score (and I should save it in database).
Popular game framework for 2D games in JS is Phaser, but I don't find any nice example for my type of like, like in example.
Game from example is created with Construct. I never used it before.
My experience in gameDev is - creating a few small games by tutorials without frameworks, and I have some knowledge with webGl (3d).
So I don't really know what should I do with it. Now I start a small tutorial based on Phaser, but I'm not sure is it right or not.
Hope, someone has some recommendation for me :)
Note: I'll not list game engines already mentioned, (that are very good anyway).
CraftyJS
As the game mechanism is very simple you can try out Crafty, it is opensource and very simple for prototyping.
It has built-in all the behaviors you are seeking for:
jump
movements with keyboard
collisions in order to colllect items
...many more built-in along with a lot of useful 3rd party components
PixiJS
If you need performances and also mobile compatibility you can take a look at the stunning PixiJS which is more a rendering engine than a game engine, but has by far the best performance vs other engines, take a look at the performance of your device in examples section.

Is phaser capable of large multiplayer games?

Newbie here. I am working with phaser, specifically with the isometric plugin.
I would like to know if it is possible to create games in phaser similar to agar.io, in terms of handling real-time multiple connections, generating a enormous map with about 300 players in it and all this without having too much impact in game performance. I seriously don't know how to handle the multiplayer part (probably sockets, node.js) for it to work really well. And as for generating a really big map I am quite blank too.
Is it possible, in phaser, to create a isometric-type game that handles multiples real time multiplayer and HUGE maps that are generated when the user gets to the edges of the visible "map"? How?
If not, what should I opt for (game engine in js and other applications) in order to achieve what I want?
You're not asking the right question, but you're close!
Your first guess is correct. You wouldn't handle multiplayer with Phaser, you'd use web sockets, or nodejs, or some other backend. So Phaser does not really limit you in what you can create with regards to multiplayer, since none of the networking code has anything to do with Phaser.
The idea of handling a huge map also just depends on how you optimize your graphics, regardless of what platform or framework you're using. For example, if you have huge or infinite maps, you can always just only show what's on screen, or around the edges of the screen, and use object pooling to show the rest of the map as the players move.
For multiplayer in Nodejs, check out Socket.io. It's really easy to use. I've set up a barebones example using it here. And in case you might find it helpful, here's an open source game I made for Ludum Dare in Phaser, with networking (this one is only p2p, so it's only made to handled 2 players connected to each other, but like I said, that's only a limitation of the multiplayer framework I used, in this case peerjs.com, and has nothing to do with Phaser itself, which can take care of all your rendering and game logic needs.)
Hopefully this helped answer some of your questions!
Phaser (at least in its 2.0 version) is not a good candidate for implementation of real time game networking as explained here.
If you're looking for a Javascript Multiplayer game engine you should check out Lance, which was written specifically for this purpose. You can then choose a renderer of your choice (Pixi.js, for example, if you're aiming to implement something like Agar.io. It's the same Renderer Phaser uses)
Regarding PhasedEvolution's comment above - Firebase is a nice tool if you're doing turn based games. It's not up to par for real-time game development as it doesn't allow low level access for any game-critical features that mitigate latency like client-size prediction, bending, interpolation and extrapolation.
Proper disclosure: I'm one of the co-creators of Lance :)

How to Implement web worker for stemkoski example

Stemkoski made an example which uses a particle system in Particle Engine. I am looking to use the logic for the candle, but will be making multiple candles and the frame rate tends to drop with just the single instance in his example.
Looking online, I came across another example of a particle system, but on a much larger scale by Ian Webster. One of the things he talks about using is web workers to prevent the UI from locking up and it seems to be the best way to go (from what I can tell).
I have tried breaking down some web worker examples, such as This, and implementing the logic into the particle engine, but I am not having any luck. Anyone know if this is even the best way to handle a larger load of particles and particle systems? And if so, what would need to be done for this situation?

WebGL graphics rendering engine

So, I have thought about designing a WebGL Graphics Engine, which will facilitate designing 3D Interactive Graphics for web. Now, my question is :
WebGL is Javascript API, so in order to design an engine for WebGL graphics, do I need to have a JavaScript compiler or anything ? What I want is a system which will let users see what they are creating (for example, like blender workspace, if you draw up a scene you can see and make changes simultaneously)
You would have to create some kind of engine, or framework that you'll build your system onto.
Creating only framework/engine would take at least 2-3 months, and if you plan creating something really big and advanced, that supports various effects rather than simple rendering primitives, than that might come down to 5-6 months. After that you could start creating your web application. So 6-7 months time for that? That shouldn't be a problem.
I don't know how advanced you are, how many people are you working with, but that seems very plausible and doable. But is worth of it? In a year, many different things will change, maybe new openGL ES version for webGL, changing api, supported browsers (IE recently joined the game),... it's really questionable.
You wouldn't need any kind of JS compiler or anything like it, just knowledge of advanced JS and many different techniques used in 3d, and since you plan building system that is far beyond just-graphic-stuff, then it adds even more to overall complexity and time consumption.
So, to answer your question: yes, it's very doable in a year, but will it pay off?
Similar things already exist in some form:
http://errolschwartz.com/projects/threescene/
http://badassjs.com/post/12885773103/threenodes-js-a-visual-webgl-scene-editor
CopperLicht engine has its own real-time editor
there are more lab-playground-like editors

Particle System in THREE.js

I am making particle System in THREE.js by using SPARK.js, but the problem is that I am done with the code that is needed for the particle System but I am unable to see any thing on the screen related to the Particle System.
I am making a flame in THREE.js but I don't know why flame is not showing in the world.
You can take look at Three.quarks!. It's one of the best particle system engine for three.js. It supports texture batching, physics engine integration and everything else.

Categories

Resources