The result is really cool, and the target FPS is pretty high (60fps), without any canvas!
What do you think about this project? Let me know! ^^
Take a look to the repo here
Top comments (21)
I lol'd at bullet.classList.add('Shooted');
I had trouble finding your game assets for the player/enemies. Are you using png or svg? My understanding is svg is the most performant for small sprites (as long as you stay away from filter effects).
I ask because I'm currently working on a project that involves svg sprites so I'm always looking for newer/better ways to handle them.
Ahah yeah that was a stupid trick to try some cool effects on the bullet when the player shoot, but it was kinda a waste of time. I want to improve it in the future but for now it’s useless 😂
I don’t use svg for enemies, I use only emoji characters because the goal of the project was different but I wish to implements some animated svg when I’ll convert all into a object oriented project..
Oh good call on the emoji characters. I bet that is even better performance.
Currently I'm importing them as ReactComponents and using inline styling + styled components. That allows me to access everything in the svg while using the React state management. Works out pretty well so far in small tests, though I confess handling the context of the variables has been a bit of a headache.
Are you working with arrow functions? These functions could help you with variable scope a lot. In React I use only these function to propagate the scope of the component into its functions like render.
I am but I'm still learning too. When I import a React component I'm often unable to access the variables inside that component and I don't know why or when that happens. I'm sure it's something obvious.
My ideal developers environment would have a color coded graph of all my variables, where they were declared, their current values, and what their scope is. Passing values - especially state/context - are an endless source of frustration for this budding developer. I find myself making bloated functions just so I can write something without having to stop and debug for an hour just to pass state.
I think you might not access the component variable, but you must define variables as component properties, and set them when you declare a component instance.
You don't need to access to the component variables if you only need to keep it dynamic, use react props to handle component variations.
Thanks! This gives me something to chew on. I keep seeing articles that are refactoring the kind of code you're showing me into hooks and ditching the constructor and super props. So I haven't even looked into that functionality because I've been trying to use hooks for everything. But perhaps yours is the more straightforward way.
I see you're using typescript too. I should probably start doing that.
I suggest you to start with the tutorials here and to learn also what nodejs is and how to use it. Take a look also on what npm is and what is a node package before starting with typescript.
I'm creating a TS version of this SpaceInvaders to improve the project readability.
Awesome! I've hooked up a node.js backend to my react app as a test / proof of concept. It's a hassle. So anything to make that easier is fantastic.
Nice; will you deploy to a website so people can play?
Yes I'll do when I'll complete the game, I need to do some score and game logic, and maybe a multiplayer version ^
BUT you can download the repository and try it by yourself ;)
Too much effort 😂
Please follow these instructions and you can have GitHub automatically serve the game on a website: help.github.com/en/articles/config...
Ahah yes I know you can host pages on GitHub like thism, I'll do this weekend probably, I'm converting the project to typescript so when I did it I'll create a playable version online ^
Good stuff haha! Hit me with that nostalgia.
Amazing work! (+1)
Amazing work! (+2)
Great job!! Looks really cool :D
Yeah thanks, it's nothing complex just a test but I'm happy to hear that! ^
Amazing work (+3)!!!!