Framerate issues with Arcade
up vote
0
down vote
favorite
So I'm making a platformer 2D game with Arcade, and for some reason, my game always goes ~30 FPS instead of going 60 FPS.
Not only that, when I press the left arrow key to move my character to the left, it goes down to ~4 FPS.
Code for my movement system (I had to make a camera)
def update(self, x):
# update player
if self.player != None:
self.player.real_x += self.player.movement
self.player.center_y -= gravityConstant
I use 'real_x' variable instead of using 'center_x' because of the camera.
Ignore the fact that the gravity doens't acelerate and always make the character fall at a constant speed (will fix that).
The player will always be in the center of the screen:
self.player.center_x = self.x / 2;
At first I thought it was that the movement of the Sprite caused lag, but when I added gravity, I noticed that the problem is only with the X axis movement. When the character falls due to gravity, it runs at 30 FPS, but when it is moving in any direction that isn't Y (X, -X) it will slow down the game to ~4 FPS.
My computer is pretty bad though, but I don't think it's the responsable for this framerate issues.
Specs:
Processor: 1.58 GHz
RAM: 3.99 / 4.00 GB
EDIT:
This happens with both left and right movements. The movement is handled through a arcade.Window class.
Code of the functions:
def onKeyDown(self, symbol):
if symbol == arcade.key.LEFT:
self.movement = -self.walk_speed;
elif symbol == arcade.key.RIGHT:
self.movement = self.walk_speed;
elif symbol == arcade.key.UP:
self.jumping = True;
def onKeyUp(self, symbol):
if symbol == arcade.key.LEFT:
self.movement = 0;
elif symbol == arcade.key.RIGHT:
self.movement = 0;
elif symbol == arcade.key.UP:
self.jumping = False;
Code of the on_key_press and on_key_release:
def on_key_press(self, symbol, modifier):
if self.player != None:
self.player.onKeyDown(symbol);
def on_key_release(self, symbol, modifier):
if self.player != None:
self.player.onKeyUp(symbol);
Note: This works with Classes, so these functions are inside a Player Class.
python python-3.x
add a comment |
up vote
0
down vote
favorite
So I'm making a platformer 2D game with Arcade, and for some reason, my game always goes ~30 FPS instead of going 60 FPS.
Not only that, when I press the left arrow key to move my character to the left, it goes down to ~4 FPS.
Code for my movement system (I had to make a camera)
def update(self, x):
# update player
if self.player != None:
self.player.real_x += self.player.movement
self.player.center_y -= gravityConstant
I use 'real_x' variable instead of using 'center_x' because of the camera.
Ignore the fact that the gravity doens't acelerate and always make the character fall at a constant speed (will fix that).
The player will always be in the center of the screen:
self.player.center_x = self.x / 2;
At first I thought it was that the movement of the Sprite caused lag, but when I added gravity, I noticed that the problem is only with the X axis movement. When the character falls due to gravity, it runs at 30 FPS, but when it is moving in any direction that isn't Y (X, -X) it will slow down the game to ~4 FPS.
My computer is pretty bad though, but I don't think it's the responsable for this framerate issues.
Specs:
Processor: 1.58 GHz
RAM: 3.99 / 4.00 GB
EDIT:
This happens with both left and right movements. The movement is handled through a arcade.Window class.
Code of the functions:
def onKeyDown(self, symbol):
if symbol == arcade.key.LEFT:
self.movement = -self.walk_speed;
elif symbol == arcade.key.RIGHT:
self.movement = self.walk_speed;
elif symbol == arcade.key.UP:
self.jumping = True;
def onKeyUp(self, symbol):
if symbol == arcade.key.LEFT:
self.movement = 0;
elif symbol == arcade.key.RIGHT:
self.movement = 0;
elif symbol == arcade.key.UP:
self.jumping = False;
Code of the on_key_press and on_key_release:
def on_key_press(self, symbol, modifier):
if self.player != None:
self.player.onKeyDown(symbol);
def on_key_release(self, symbol, modifier):
if self.player != None:
self.player.onKeyUp(symbol);
Note: This works with Classes, so these functions are inside a Player Class.
python python-3.x
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
So I'm making a platformer 2D game with Arcade, and for some reason, my game always goes ~30 FPS instead of going 60 FPS.
Not only that, when I press the left arrow key to move my character to the left, it goes down to ~4 FPS.
Code for my movement system (I had to make a camera)
def update(self, x):
# update player
if self.player != None:
self.player.real_x += self.player.movement
self.player.center_y -= gravityConstant
I use 'real_x' variable instead of using 'center_x' because of the camera.
Ignore the fact that the gravity doens't acelerate and always make the character fall at a constant speed (will fix that).
The player will always be in the center of the screen:
self.player.center_x = self.x / 2;
At first I thought it was that the movement of the Sprite caused lag, but when I added gravity, I noticed that the problem is only with the X axis movement. When the character falls due to gravity, it runs at 30 FPS, but when it is moving in any direction that isn't Y (X, -X) it will slow down the game to ~4 FPS.
My computer is pretty bad though, but I don't think it's the responsable for this framerate issues.
Specs:
Processor: 1.58 GHz
RAM: 3.99 / 4.00 GB
EDIT:
This happens with both left and right movements. The movement is handled through a arcade.Window class.
Code of the functions:
def onKeyDown(self, symbol):
if symbol == arcade.key.LEFT:
self.movement = -self.walk_speed;
elif symbol == arcade.key.RIGHT:
self.movement = self.walk_speed;
elif symbol == arcade.key.UP:
self.jumping = True;
def onKeyUp(self, symbol):
if symbol == arcade.key.LEFT:
self.movement = 0;
elif symbol == arcade.key.RIGHT:
self.movement = 0;
elif symbol == arcade.key.UP:
self.jumping = False;
Code of the on_key_press and on_key_release:
def on_key_press(self, symbol, modifier):
if self.player != None:
self.player.onKeyDown(symbol);
def on_key_release(self, symbol, modifier):
if self.player != None:
self.player.onKeyUp(symbol);
Note: This works with Classes, so these functions are inside a Player Class.
python python-3.x
So I'm making a platformer 2D game with Arcade, and for some reason, my game always goes ~30 FPS instead of going 60 FPS.
Not only that, when I press the left arrow key to move my character to the left, it goes down to ~4 FPS.
Code for my movement system (I had to make a camera)
def update(self, x):
# update player
if self.player != None:
self.player.real_x += self.player.movement
self.player.center_y -= gravityConstant
I use 'real_x' variable instead of using 'center_x' because of the camera.
Ignore the fact that the gravity doens't acelerate and always make the character fall at a constant speed (will fix that).
The player will always be in the center of the screen:
self.player.center_x = self.x / 2;
At first I thought it was that the movement of the Sprite caused lag, but when I added gravity, I noticed that the problem is only with the X axis movement. When the character falls due to gravity, it runs at 30 FPS, but when it is moving in any direction that isn't Y (X, -X) it will slow down the game to ~4 FPS.
My computer is pretty bad though, but I don't think it's the responsable for this framerate issues.
Specs:
Processor: 1.58 GHz
RAM: 3.99 / 4.00 GB
EDIT:
This happens with both left and right movements. The movement is handled through a arcade.Window class.
Code of the functions:
def onKeyDown(self, symbol):
if symbol == arcade.key.LEFT:
self.movement = -self.walk_speed;
elif symbol == arcade.key.RIGHT:
self.movement = self.walk_speed;
elif symbol == arcade.key.UP:
self.jumping = True;
def onKeyUp(self, symbol):
if symbol == arcade.key.LEFT:
self.movement = 0;
elif symbol == arcade.key.RIGHT:
self.movement = 0;
elif symbol == arcade.key.UP:
self.jumping = False;
Code of the on_key_press and on_key_release:
def on_key_press(self, symbol, modifier):
if self.player != None:
self.player.onKeyDown(symbol);
def on_key_release(self, symbol, modifier):
if self.player != None:
self.player.onKeyUp(symbol);
Note: This works with Classes, so these functions are inside a Player Class.
python python-3.x
python python-3.x
edited Nov 11 at 3:04
asked Nov 11 at 2:11
VetraDebesis
698
698
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Do you mind putting the part of the code responsible for the movements?
also, check where you put things on screen, you want to make a variable, set it to the image, and call that var. as for it only happening when moving left , make sure the left script is the same as right but - instead of +.
It doens't only happen to the left movement, it also happens to the right movement. Code of the movement:def onKeyDown(self, symbol): if symbol == arcade.key.LEFT: self.movement = -self.walk_speed; elif symbol == arcade.key.RIGHT: self.movement = self.walk_speed; def onKeyUp(self, symbol): if symbol == arcade.key.LEFT: self.movement = 0; elif symbol == arcade.key.RIGHT: self.movement = 0; elif symbol == arcade.key.UP: self.jumping = False;
And this is handled by the Game class, with on_key_press, and on_key_release.
– VetraDebesis
Nov 11 at 2:52
for your gravity, check the code. also, it may be the library you use, i recomend the "Keyboard" Library, or the one in pygame. your movement should be handled the same, whether it be y or x. make the X code the y code but with if its button is pushed down.
– idk
Nov 18 at 1:14
also, when you move the char, dont wait to upddate the character to move it. just move it then.
– idk
Nov 18 at 1:17
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Do you mind putting the part of the code responsible for the movements?
also, check where you put things on screen, you want to make a variable, set it to the image, and call that var. as for it only happening when moving left , make sure the left script is the same as right but - instead of +.
It doens't only happen to the left movement, it also happens to the right movement. Code of the movement:def onKeyDown(self, symbol): if symbol == arcade.key.LEFT: self.movement = -self.walk_speed; elif symbol == arcade.key.RIGHT: self.movement = self.walk_speed; def onKeyUp(self, symbol): if symbol == arcade.key.LEFT: self.movement = 0; elif symbol == arcade.key.RIGHT: self.movement = 0; elif symbol == arcade.key.UP: self.jumping = False;
And this is handled by the Game class, with on_key_press, and on_key_release.
– VetraDebesis
Nov 11 at 2:52
for your gravity, check the code. also, it may be the library you use, i recomend the "Keyboard" Library, or the one in pygame. your movement should be handled the same, whether it be y or x. make the X code the y code but with if its button is pushed down.
– idk
Nov 18 at 1:14
also, when you move the char, dont wait to upddate the character to move it. just move it then.
– idk
Nov 18 at 1:17
add a comment |
up vote
0
down vote
Do you mind putting the part of the code responsible for the movements?
also, check where you put things on screen, you want to make a variable, set it to the image, and call that var. as for it only happening when moving left , make sure the left script is the same as right but - instead of +.
It doens't only happen to the left movement, it also happens to the right movement. Code of the movement:def onKeyDown(self, symbol): if symbol == arcade.key.LEFT: self.movement = -self.walk_speed; elif symbol == arcade.key.RIGHT: self.movement = self.walk_speed; def onKeyUp(self, symbol): if symbol == arcade.key.LEFT: self.movement = 0; elif symbol == arcade.key.RIGHT: self.movement = 0; elif symbol == arcade.key.UP: self.jumping = False;
And this is handled by the Game class, with on_key_press, and on_key_release.
– VetraDebesis
Nov 11 at 2:52
for your gravity, check the code. also, it may be the library you use, i recomend the "Keyboard" Library, or the one in pygame. your movement should be handled the same, whether it be y or x. make the X code the y code but with if its button is pushed down.
– idk
Nov 18 at 1:14
also, when you move the char, dont wait to upddate the character to move it. just move it then.
– idk
Nov 18 at 1:17
add a comment |
up vote
0
down vote
up vote
0
down vote
Do you mind putting the part of the code responsible for the movements?
also, check where you put things on screen, you want to make a variable, set it to the image, and call that var. as for it only happening when moving left , make sure the left script is the same as right but - instead of +.
Do you mind putting the part of the code responsible for the movements?
also, check where you put things on screen, you want to make a variable, set it to the image, and call that var. as for it only happening when moving left , make sure the left script is the same as right but - instead of +.
answered Nov 11 at 2:37
idk
154
154
It doens't only happen to the left movement, it also happens to the right movement. Code of the movement:def onKeyDown(self, symbol): if symbol == arcade.key.LEFT: self.movement = -self.walk_speed; elif symbol == arcade.key.RIGHT: self.movement = self.walk_speed; def onKeyUp(self, symbol): if symbol == arcade.key.LEFT: self.movement = 0; elif symbol == arcade.key.RIGHT: self.movement = 0; elif symbol == arcade.key.UP: self.jumping = False;
And this is handled by the Game class, with on_key_press, and on_key_release.
– VetraDebesis
Nov 11 at 2:52
for your gravity, check the code. also, it may be the library you use, i recomend the "Keyboard" Library, or the one in pygame. your movement should be handled the same, whether it be y or x. make the X code the y code but with if its button is pushed down.
– idk
Nov 18 at 1:14
also, when you move the char, dont wait to upddate the character to move it. just move it then.
– idk
Nov 18 at 1:17
add a comment |
It doens't only happen to the left movement, it also happens to the right movement. Code of the movement:def onKeyDown(self, symbol): if symbol == arcade.key.LEFT: self.movement = -self.walk_speed; elif symbol == arcade.key.RIGHT: self.movement = self.walk_speed; def onKeyUp(self, symbol): if symbol == arcade.key.LEFT: self.movement = 0; elif symbol == arcade.key.RIGHT: self.movement = 0; elif symbol == arcade.key.UP: self.jumping = False;
And this is handled by the Game class, with on_key_press, and on_key_release.
– VetraDebesis
Nov 11 at 2:52
for your gravity, check the code. also, it may be the library you use, i recomend the "Keyboard" Library, or the one in pygame. your movement should be handled the same, whether it be y or x. make the X code the y code but with if its button is pushed down.
– idk
Nov 18 at 1:14
also, when you move the char, dont wait to upddate the character to move it. just move it then.
– idk
Nov 18 at 1:17
It doens't only happen to the left movement, it also happens to the right movement. Code of the movement:
def onKeyDown(self, symbol): if symbol == arcade.key.LEFT: self.movement = -self.walk_speed; elif symbol == arcade.key.RIGHT: self.movement = self.walk_speed; def onKeyUp(self, symbol): if symbol == arcade.key.LEFT: self.movement = 0; elif symbol == arcade.key.RIGHT: self.movement = 0; elif symbol == arcade.key.UP: self.jumping = False;
And this is handled by the Game class, with on_key_press, and on_key_release.– VetraDebesis
Nov 11 at 2:52
It doens't only happen to the left movement, it also happens to the right movement. Code of the movement:
def onKeyDown(self, symbol): if symbol == arcade.key.LEFT: self.movement = -self.walk_speed; elif symbol == arcade.key.RIGHT: self.movement = self.walk_speed; def onKeyUp(self, symbol): if symbol == arcade.key.LEFT: self.movement = 0; elif symbol == arcade.key.RIGHT: self.movement = 0; elif symbol == arcade.key.UP: self.jumping = False;
And this is handled by the Game class, with on_key_press, and on_key_release.– VetraDebesis
Nov 11 at 2:52
for your gravity, check the code. also, it may be the library you use, i recomend the "Keyboard" Library, or the one in pygame. your movement should be handled the same, whether it be y or x. make the X code the y code but with if its button is pushed down.
– idk
Nov 18 at 1:14
for your gravity, check the code. also, it may be the library you use, i recomend the "Keyboard" Library, or the one in pygame. your movement should be handled the same, whether it be y or x. make the X code the y code but with if its button is pushed down.
– idk
Nov 18 at 1:14
also, when you move the char, dont wait to upddate the character to move it. just move it then.
– idk
Nov 18 at 1:17
also, when you move the char, dont wait to upddate the character to move it. just move it then.
– idk
Nov 18 at 1:17
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245257%2fframerate-issues-with-arcade%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown