2DGame | A simple 2D sprite bouncing around the screen
kandi X-RAY | 2DGame Summary
kandi X-RAY | 2DGame Summary
A simple 2D sprite bouncing around the screen, written in Java for Android
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Main loop
- Update the velocity
- Draws the character sprite
- Draws the image onto the canvas
- Update the sprite sprite
- Invoked when a thread is destroyed
- Set if running
- Initializes this widget
- Create a character sprite
- On touch events
2DGame Key Features
2DGame Examples and Code Snippets
Community Discussions
Trending Discussions on 2DGame
QUESTION
what is best practice so save game progress for a simple 2D game? With "progress" I mean really simple values like "number of collected items" (int), "highscore" (int), "amount of currency" (float) and "is avatar unlocked" (bool). There is no worldmap state or anything big to be saved. I used playerprefs but this is designed for preferences and should be avoided according to many experts. That's why I want to change this now.
I read this thread: Stackoverflow Question, but I cannot identify the best solution for my case as there is no comparison of the proposed methods.
My requirements are simply:
- applicable for iOS and Android
- not being deleted when a new Version of the App is published
- easy to use in the script as we refer at many points to the variables
Any suggestions?
...ANSWER
Answered 2020-Jul-25 at 00:33Personnaly, I like to write directly into a file. It's applicable to all platforms, isn't removed on an app update, and you have full control over the way you access the data. It's easy to add, remove, edit the contents, and easy to handle multiple save states.
You can do it with a simple class, such as this one :
QUESTION
I'm just getting started with webgl. I followed a simple beginners tutorial on youtube. Now, I'm trying to create a simple 2D game.
In that game, I want to render a simple inventory with images. When I do this, my fps drops down to 2 after 10 seconds. If I remove the code for the inventory rendering, it stays at 60.
I know that my problem is on line 82 in game/js/engine/inventory/inventory.js
. There, I render 35 images with a sprite class that I made watching the tutorial. I think because I watched a simple tutorial in which the code that is rendering the image isn't optimized and probably isn't the best way to do it. The sprite class is located in game/js/engine/material.js:127
. In the sprite class, I setup simple variables that can be parsed to my vertex and fragment shader.
In the setup method I setup all the parameters for my image.
...ANSWER
Answered 2020-Jun-13 at 03:49is a better way to render an inventory?
There are a few ways to optimize off the top of my head.
It might be faster to just use HTML for your inventory
Seriously: You also gain easy international font rendering, styling, responsiveness with CSS, etc... Plenty of games do this.
It's generally faster to use a texture atlas (a single texture with lots of different images), then generate vertices into a vertex buffer for all the parts of your inventory. Then draw all of it with a single draw call. This is how for example Dear ImGUI works to make all of these amazing GUIs. It doesn't draw anything itself, it just generates a vertex buffer with positions and texture coordinates for a texture atlas.
Do #2 except instead of generating the entire vertex buffer every frame just update the parts that change.
So for example let's say your inventory says
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install 2DGame
You can use 2DGame like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the 2DGame component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page