im trying to make a mario clone in ruby using gosu. when i want to make the blocks hitable, i also loop thru the array just like in the video but it will always take the hitbox for the last block in the array.
at about 15 mins i start to get this error Exception in thread "Thread-1" java.lang.ArrayIndexOutOfBoundsException: 3 at com.kody.game.entities.Player.tick(Player.java:50) at com.kody.game.gamestate.Level1State.tick(Level1State.java:36) at com.kody.game.gamestate.GameStateManager.tick(GameStateManager.java:17) at com.kody.game.main.GamePanel.tick(GamePanel.java:70) at com.kody.game.main.GamePanel.run(GamePanel.java:50) at java.lang.Thread.run(Unknown Source) pressing enter at the main screen will not bring me into the game, and i also cannot navigate the home menu.. i thaught i copies yours exactly but i guess not.
Stockman If you keep moving, that means something's not making right and left = false. Make sure in GameState Manager, game panel, and level 1 state, you have Keypressed under the Keypressed methods, and keyReleased under the keyReleased methods. Example: public void keyPressed(int e)
at like 15 minutes in the video I get this error Exception in thread "Thread-1" java.lang.ArrayIndexOutOfBoundsException: 3 at com.patrickfeltes.game.gamestate.Level1State.tick(Level1State.java:33) at com.patrickfeltes.game.gamestate.GameStateManager.tick(GameStateManager.java:16) at com.patrickfeltes.game.main.GamePanel.tick(GamePanel.java:69) at com.patrickfeltes.game.main.GamePanel.run(GamePanel.java:50) at java.lang.Thread.run(Unknown Source) when trying to run the game. any help or advice?
why now left arrow is up and right arrow is still right? what i did wrong? :\ package me.Bamba.game.entities; import java.awt.Color; import java.awt.Graphics; import java.awt.Point; import java.awt.event.KeyEvent; import me.Bamba.game.gamestate.GameState; import me.Bamba.game.objects.Block; import me.Bamba.game.physics.Collision; import me.alon.game.main.GamePanel; public class Player { // movement booleans private boolean right = false, left = false, jumping = false, falling = false; // bounds private double x, y; private int width, height; // move speed private double moveSpeed = 2.5; // jump speed private double jumpSpeed = 5; private double currentJumpSpeed = jumpSpeed; // fall speed public double maxFallSpeed = 5; public double currentFallSpeed = 0.1; public Player (int width, int height) { x = GamePanel.WIDTH / 2; y = GamePanel.HEIGHT / 2; this.width = width; this.height = height; } public void tick(Block[] b) { int iX = (int)x; int iY = (int)y; for (int i = 0; i < b.length; i++) { // right if(Collision.playerBlock(new Point(iX + width, iY), b[i]) || Collision.playerBlock(new Point(iX + width, iY + height), b[i])) { } }
if (right) { GameState.xOffset += moveSpeed; } if (left) { GameState.yOffset -= moveSpeed; } if (jumping) { GameState.yOffset -= currentJumpSpeed; currentJumpSpeed -= .1; if(currentJumpSpeed
FaZe Bamba if left is press, we want to go left. So we have to move the xOffset, not the yOffset. if (left) gameState.xOffset -= movespeed; I have no idea why he put yOffset, and it's even more confusing of why it works for him lol.
In this tutorial you barely explain anything. Why would you say "Tutorial", and not teach us anything? copying the code doesn't do anything for us. Rename these to "Showing you how to make a platformer #".... Instead of lying to us.
im trying to make a mario clone in ruby using gosu. when i want to make the blocks hitable, i also loop thru the array just like in the video but it will always take the hitbox for the last block in the array.
Whenever I add the collision it won't let me use "Or" statements.
what is the shortcut key to import liberaries?
Is it just me but it's super laggy :( how do I fix this? Also thanks so much!!!
whenever i move one way, it won't stop moving, and i have the controls down correctly
well now that i did the x-gamestate.xoffset and such u can stop moving, but then i cannot start again
at about 15 mins i start to get this error
Exception in thread "Thread-1" java.lang.ArrayIndexOutOfBoundsException: 3
at com.kody.game.entities.Player.tick(Player.java:50)
at com.kody.game.gamestate.Level1State.tick(Level1State.java:36)
at com.kody.game.gamestate.GameStateManager.tick(GameStateManager.java:17)
at com.kody.game.main.GamePanel.tick(GamePanel.java:70)
at com.kody.game.main.GamePanel.run(GamePanel.java:50)
at java.lang.Thread.run(Unknown Source)
pressing enter at the main screen will not bring me into the game, and i also cannot navigate the home menu.. i thaught i copies yours exactly but i guess not.
Buttomn collision doesnt work :\
When I press the a or d, it stars to move then doesnt stop, HELP
package stockman.entities;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
import com.sun.glass.events.KeyEvent;
import stockman.gamestate.GameState;
import stockman.main.GamePanel;
import stockman.phyics.Collision;
import stocman.objects.Block;
public class Player extends Rectangle{
private static final long serialVersionUID = 1L;
//movement booleans
private boolean right = false, left = false, jumping = false, falling = false;
private double moveSpeed = 2.5;
//bounds
private double x, y;
private int width, height;
//jumpspeed
private double jumpSpeed = 5;
private double currentJumpSpeed = jumpSpeed;
//fallspeed
private double fallSpeed = 5;
private double currentFallSpeed = fallSpeed;
public Player(int width, int height){
x = GamePanel.WIDTH /2;
y = GamePanel.HEIGHT / 2;
this.width = width;
this.height = height;
}
public void tick(Block[] b){
int iX = (int)x;
int iY = (int)y;
for(int i = 0; i < b.length; i++){
//right
if(Collision.playerBlock(new Point(iX + width, iY), b[i]) ||
Collision.playerBlock(new Point(iX + width, iY + height), b[i]))
{
right = false;
}
}
if(right) {GameState.xOffset += moveSpeed;}
if(left) {GameState.yOffset += moveSpeed;}
if(jumping) {
y -= currentJumpSpeed;
currentJumpSpeed -= 1;
if(currentJumpSpeed
Stockman If you keep moving, that means something's not making right and left = false. Make sure in GameState Manager, game panel, and level 1 state, you have Keypressed under the Keypressed methods, and keyReleased under the keyReleased methods.
Example:
public void keyPressed(int e)
Thanks for that !!!! I realised that I had keypressed on both and it's working now :)
at like 15 minutes in the video I get this error
Exception in thread "Thread-1" java.lang.ArrayIndexOutOfBoundsException: 3
at com.patrickfeltes.game.gamestate.Level1State.tick(Level1State.java:33)
at com.patrickfeltes.game.gamestate.GameStateManager.tick(GameStateManager.java:16)
at com.patrickfeltes.game.main.GamePanel.tick(GamePanel.java:69)
at com.patrickfeltes.game.main.GamePanel.run(GamePanel.java:50)
at java.lang.Thread.run(Unknown Source)
when trying to run the game. any help or advice?
why now left arrow is up
and right arrow is still right? what i did wrong? :\
package me.Bamba.game.entities;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.event.KeyEvent;
import me.Bamba.game.gamestate.GameState;
import me.Bamba.game.objects.Block;
import me.Bamba.game.physics.Collision;
import me.alon.game.main.GamePanel;
public class Player {
// movement booleans
private boolean right = false, left = false, jumping = false, falling = false;
// bounds
private double x, y;
private int width, height;
// move speed
private double moveSpeed = 2.5;
// jump speed
private double jumpSpeed = 5;
private double currentJumpSpeed = jumpSpeed;
// fall speed
public double maxFallSpeed = 5;
public double currentFallSpeed = 0.1;
public Player (int width, int height) {
x = GamePanel.WIDTH / 2;
y = GamePanel.HEIGHT / 2;
this.width = width;
this.height = height;
}
public void tick(Block[] b) {
int iX = (int)x;
int iY = (int)y;
for (int i = 0; i < b.length; i++) {
// right
if(Collision.playerBlock(new Point(iX + width, iY), b[i])
|| Collision.playerBlock(new Point(iX + width, iY + height), b[i])) {
}
}
if (right) {
GameState.xOffset += moveSpeed;
}
if (left) {
GameState.yOffset -= moveSpeed;
}
if (jumping) {
GameState.yOffset -= currentJumpSpeed;
currentJumpSpeed -= .1;
if(currentJumpSpeed
FaZe Bamba if left is press, we want to go left. So we have to move the xOffset, not the yOffset.
if (left) gameState.xOffset -= movespeed;
I have no idea why he put yOffset, and it's even more confusing of why it works for him lol.
at 17 minutes, when i press a or d I go always left :[
I had the same problem, in the collision class I had return b.contains(b); it should be return b.contains(p);
In this tutorial you barely explain anything. Why would you say "Tutorial", and not teach us anything? copying the code doesn't do anything for us. Rename these to "Showing you how to make a platformer #".... Instead of lying to us.
if you have difficulty to learn this, go study java.