I am working on a really, really simple rendition of the parachute shooter game, all in javascript.I am pretty new to javascript, with a background in java and OOP. Maybe I'm completely wrong here and maybe I just don't have any understanding of how javascript works, but the way I see it, I have two options to track the falling parachuters.
I can either create multiple parachuter objects and store them in some array of size n, however many can exist on the game field at one time or I can somehow create multiple threads of the parachuter object within the game board that will act independently of each other and only interact with the rockets being fired at them.
I'm not very familiar with the second option and don't really know how that would be achieved. I'm open to any pointers and different ideas for how to handle all of the parachuters. Which of those two is more efficient and manageable? Are both of them feasible? I don't necessarily want someone to give me their code for those (though it would be helpful), I just want to talk about theory and method.
Thanks for any help in advance.
Related
As a beginning note, I'm writing a discord bot with Discord.js. And sorry for the potentially confusing title.
The basic functionality of the bot is that it helps multiple users play card games together, say for example Go Fish.
I'd like to eventually add the functionality for server admin to write and add their own "mods," (modifications) to spice up whatever game they'd like. In this case, someone could make it so that the game would require either 4 or 2 cards to complete a set in Go Fish, depending on if the mod is enabled for a specific instance of the game, or perhaps modify the drawCard() method to continue drawing cards until the player gets a card they already have at least one of. (or honestly do whatever with the original game, doesn't matter.)
As of my current code, I have a few basic classes, with a specific class coreGame, and then different "base games" which extend coreGame, providing basic functionality for all types of card games. When a user wants to play a game, I won't know which mods are available, since they're server-specific. The best I think can do is create a new instance of baseGoFish (My original, unmodified implementation of the base game which isn't server-specific)
I'm thinking that mods would extend the base game, like class modExample extends baseGoFish {...}, but I'm not sure how I would create an instance of the modded game, and even less sure if there were multiple mods.
As another note, I think have to call mods' methods twice, once before the base game's actual code, (so that it can choose to cancel the base game's methods, as if it were an event, or do its own thing unrelated to the base game), and once after, so that mods could edit what the base game just did. This specific part seems pretty jank and likely to break, so what would be a better solution here as well?
I've looked briefly into mixins, and those seem like they'll help here, but I'm unsure of how to properly implement them, as I've never used them before (much less used javascript with classes.)
Recently, I have been extensively exploring the source code for this Three.js example: gpgpu / water.
I think that this example is super cool, and I was hoping to use the values of the water to affect certain things in other parts of my script (perhaps mapping one of the values to an oscillator's frequency). However, I have not been able to find what is actually changing in the data. Anyone can plainly see that some kind of data is changing. If you show the wireframe, then you can see vertices and lines moving in 3D space. Something is changing! But I can't find what it is.
I'm pretty sure that the custom shader has a lot to do with me being unable to find anything. Perhaps the values are hidden somewhere in GPU Land where I can't access them, but I have no idea. I've even looked at values within the GPUComputationRenderer.js script that's used to help with this example, but EVERYTHING seems to be static.
Granted, I'm pretty new to 3D graphics in general, so all of my findings and assumptions may be wrong. Either way, I just want someone to tell me where some kind of data is changing.
A huge thanks to anyone that can help me out with this! At this point, I just want to regain my sanity.
I have a 10x10 grid filled with objects in certain coordinates and I have a character that needs to get from the start to finish but I would like to avoid the certain coordinates on the route to the finish. Could someone please tell what would be the best way of approaching this in Javascript.
Also, if I was to initialise an array with the obstacles in an array how would I best code this to avoid those certain plots.
Thank you.
Sounds like you're looking for a pathfinding algorithm. The only one that comes to mind is A-Star, or "A*". The short version is that it recursively picks a random "next node" from the nodes it hasn't checked, being more likely to pick nodes that are physically closer to the goal. This is a commonly-used function that you may want to find a tutorial for (it doesn't have to be a JavaScript tutorial as long as you can reuse the concepts in JavaScript)
I want to make a moving man in css/html/javascript, also detect collisions with other objects. Any idea how to do it? or any pointers to the same will do great.
The first try is look at rapahel js project it uses canvas, second it is a pretty hard thing to do as you want your own physics engine at 2 D level, but i guess with some math formulas you could do it, but everything that you need as an object should be scripted in js to be sure to get the collision effect.
Some design patterns should help you to make your code better.
Good luck.
Pretty much any basic game tutorial covers the topics you asked.
If you can't find a javascript version of that, just get anything in a language you are familiar and try to code the same thing in javascript.
to draw things somewhat in the same way these tutorials probably do, use a div with "position:relative" and its children with "position:absolute" and use "top" and "left" css style proprieties to position the boxes/sprites/whatever.
I am pretty sure you can figure out what to do if you follow these tips.
I'm trying to learn how to program a (virtual) Trading Card Game game (similar to Magic the Gathering) in Javascript. I've read a little about MVC architecture and controllers, but it's all over my head (I don't have any formal CS education) and I'm wondering if anyone has any good links or tips about how I might learn more about code architecture at a beginner's level.
Would each "card" be represented as an object, and all the logic of the cards' rules be wrapped inside one large game engine function, or many small functions that are connected to each other?
Here's an example question:
Imagine there's a card which says, "When this card comes into play, draw a card." How should I architect the game to prepare for this situation, and how is it triggered (most efficiently)? Does the card trigger the game engine, or does the game engine parse each card that's played?
Here's another example:
Imagine there's a card which says, "All your cards cost 1 less to play." and it stays in play permanently. How does the game understand that it needs to alter its rules in this case? Is this a function which listens for card to be played and interrupts the cost? As each turn resolves, where is this rule stored? Are there variables which store the base rules of the game (global card cost modifier: 0; your card cost modifier: 0) and other variables which store those new rules which cards introduce (your card cost modifier: -1), or are these variables dynamically created by the game engine as cards alter the rules (your elf cost modifier: -2)? And how do the rules know to change when a card has been destroyed, thus removing the card's rule modification?
Is what I need a primer on listeners and events? (I don't really know anything about them, but I've seen references to them from time to time.) Could you point me in the direction of a good resource?
To be clear, I'm not trying to make a long-winded request for folks to manually Google for me; I'm blindly fumbling in the dark and asking if someone would point me to the right words or phrases to search. Thank you!
There is a very nice blog about recreating a similar card game: Hearthstone from Blizzard. Allthough it is written in C# and uses Unity as a view layer, you get a pretty good understanding of how one goes about creating a suitable architecture for such a game. A fair warning though, recreating Magic the Gathering in Javascript can prove incredibly complicated and mess with your head a lot (I have first hand experience).
Blog: http://theliquidfire.com/2017/08/21/make-a-ccg-intro/
You need to go a level deeper here and think about the "game" itself. The game you're describing will actually be built around a "state machine" which is a core CS concept you should dive into and understand before you start building.
The rules of your game are going to be a state machine and the events (cards) triggered (by being played) during your game can modify those rules. You'll want some kind of interpreter to "read" the card and to modify either the rules or the game state. And then you'll need something to iterate the game through turns and phases, reading the state and taking appropriate action.
You'll also want to learn about stacks. If your game lets players interrupt each other you'll need a way to keep track of which event should happen first because events will want to be able to affect, block, redirect other events. A stack will help you keep track of that ordering.