sei-ec-remote / project-1-issues

Open new issues here
1 stars 2 forks source link

Game project issue #136

Closed EvanChenoweth closed 1 year ago

EvanChenoweth commented 2 years ago

What's the problem you're trying to solve?

Trying to find a way to give my Projectile Class a way to inherit it's X and Y position on my Canvas from the Player Class. Trying to also have it inherit the Direction from the Player Class (The direction at the time that a button is pressed)

Post any code you think might be relevant (one fenced block per file)

ALL CODE IS RELEVANT

ALL CODE IS RELEVANT

If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?

There is no error message, I am able to get my Projectile Rectangle onto my screen but I have not been able to find a way to give the Projectile Class the same X, Y coordinates as my Player has, and haven't found a way to give it the same Direction as the Direction the player was moving in when they press the button to call the projectile.

What is your best guess as to the source of the problem?

I'm not sure, I feel like I've tried everything like setting the creation position of the Projectile class to be at the player.x and player.y, but it just stays at 0,0 and I don't really know why. My guess is that player.x and player.y aren't actually moving although visually it appears to be doing so?

What things have you already tried to solve the problem?

I have tried setting my Projectile class creation variable to be created at the player.x and player.y positions, but it seems to not be working as intended.

I have also tried to give the direction to the projectile by inheriting it from the player, but since I don't really know why it wont even inherit the render location from the player I cannot get it to inherit the direction from the player either. In place of that, I tried to give the Projectile Class it's own direction handler (identical to the ones used in the players overall movement handler) in order to set the direction to a direction that matches the same direction being used by the player and the projectile at the same time, and removing the keyup function that allows the projectile to stop traveling in that direction.

Paste a link to your repository here

https://github.com/EvanChenoweth/Evan-Chenoweth-Project1

EvanChenoweth commented 2 years ago

I've now gotten the projectile to move in a direction independent of the player, but now need to know how I can tie the creation of this projectile to a keydown event, and also to have the projectile render position be that of the players x,y current location.

EvanChenoweth commented 2 years ago

Figured out how to get the projectile to inherit players position, still need help on figuring out how to tie this to a keydown event, for example when pressing J it should render the projectile. I think my main source of confusion is that where where I create this keydown function, trying to put it in my gameLoop function always seems to make the entire file act abnormally.