Hot answers tagged

2

Expanding on Greffin28's Answer Tile Based Collision Detection in Games In tile based games it's really easy and fast to detect whether an object is colliding with a tile. Some psuedo- code to accomplish this: /** * Moves our entity along the x, then y. If we do both at the same time the entity * will not move if any of the collision detections fail ...


2

For accessing the array i suggest you make a function like the following: String getState(int x, int y) { if (x < 0 || x >= WIDTH || y < 0 || y >= HEIGHT) return "g"; // Let's say all blocks outside the map is solid. return blocks[y][x].state; } This simple function can save you from array out of bounds error. Basically, the function ...


2

I suppose the Tile class is the class of which all the "balls" are an object of? (i dont have much time to read the code). If i understand correctly, what you are asking is how to change the balls color? if yes, i would suggest that when you want to change a balls color just get the tiles from your Tiles array and just: board[x][y].background = //the new ...


1

This is most likely because to make more than one instance of this you will need an array of these objects. Usually there would only be one player and multiple enemies so the player would be a single object and the enemies an array. Here's do simple code to explain this: Enemy[] enemies = new Enemies[10]; for (int i = 0; i < enemies.length; i++) { ...


1

An Alternative Approach As very astutely stated by Dan in the comments to your question, trigonometric functions are very expensive to calculate and for something as simple as a bouncy ball you can keep to simple and fast vector math. It appears that you're only doing AABB collision so this method will work perfectly for you. What to change Your Ball ...


1

It would appear your rendering logic is completely flawed. Take a look at this question and it's answers, you appear to be doing some of the same errors I previously did. Canvas - good rendering practices? About Projectiles Drawing one rectangle will literally never have any noticeable impact on your frames so there is obviously a flaw elsewhere, ...


1

From my experience, it's not expensive to bind textures. I have a program that binds about 30 textures per frame and it runs pretty smooth. Since you're using only 9 textures and VBOs on top of that, I imagine your game actually runs very well.


1

A first aproach could be giving a varying weight to each type of block, modifying such weight each level, decressing the probability of spawning an easy blocks and increasing the probability to spawn a harder ones. I'm also going to suppose you have some kind of a parent Block class and different child classes for each type of block. public Block ...



Only top voted, non community-wiki answers of a minimum length are eligible