Trying to get some basic physics going

Hello All,

Looking to implement a stickman with basic physics; no animation yet.

Using console.log(), I can see that the y-coordinate of my avatar is changing; however, all the keys defined in relation to x and y don’t change.

I figure this is a value vs. reference problem here, but I don’t know how to get around it.

Bottom line, I need to find a way to update the key points with the accurate coordinates of the avatar, so I can observe gravity in effect.

Any thoughts?

SIDE QUESTION: I figure at some point I want to move to sprite sheets and away from drawing at every step. Anyone know a good place to find sprite sheets or make custom ones myself?

Thank you!

this.coor = new Coor(x,y);
.
.
.
this.keys = {
		lFoot : [this.coor.x+(5*this.w/16),this.coor.y+(this.h*0.85)],
		rFoot : [this.coor.x+(11*this.w/16),this.coor.y+(this.h*0.85)],
		groin : [this.coor.x+(this.w/2),this.coor.y+(this.h*0.6)],
		torso : [this.coor.x+(this.w/2),this.coor.y+(this.h*0.4)],
		lElbow : [this.coor.x+(this.w/4),this.coor.y+(this.h*(16/30))],
		lHand : [this.coor.x+(this.w/8),this.coor.y+(this.h*(19/30))],
		rElbow : [this.coor.x+(this.w*3/4),this.coor.y+(this.h*(11/30))],
		rHand : [this.coor.x+(this.w*7/8),this.coor.y+(this.h*0.3)],
		wand : [this.coor.x+(this.w*9/8),this.coor.y+(this.h*0.2)],
		wandTip : [this.coor.x+(this.w*19/16),this.coor.y+(this.h*(5/30))],
		neck : [this.coor.x+(this.w/2),this.coor.y+(this.h*0.3)],
		head : [this.coor.x+(this.w/2),this.coor.y+(this.h*0.15)],
		headR : 12
	}

opengameart.org/ might be useful.

For physics in general (in JavaScript), I highly recommended youtube videos by Dan Shiffman, aka the coding train as a great start.

1 Like