Jump to content

Panda 2 development


enpu
 Share

Recommended Posts

Hi, if you don't mind, I plan to post a request/suggestion for Panda every now and then. I had trouble choosing whether to put them here or in individual new threads. I guess I'll just put them here for now, as this thread has to do with developing the new version. I can make new threads if that's more appropriate though.

 

Anyways, here's my first suggestion/request for now:

 

One command simple physics switch. Since simple physics (for collisions at least) is pretty common, it might be nice if there was a more straightforward and intuitive way to activate it.

 

For example, maybe when you extend Sprite, along with supplying a value for the texture or interactive property, maybe there could be an autoPhysics boolean property that triggers a lot of the boilerplate statements that maybe the majority of people do for basic physics, i.e. create a body named body, set its position to the position of the sprite, create a rectangle shape the same size as the sprite texture, add the body to the world, remove body when you remove object, etc.

 

This is surely not the best way to do this, but I couldn't help but feel that all these extra steps just to get an object with basic collisions is a bit of a barrier to a beginner. At the same time, I also wouldn't want to start a slippery slope of all sorts of easy toggles all over the place.

 

Just thinking out loud.

Link to comment
Share on other sites

Well you can easily make your own class, like PhysicsSprite, that extends Sprite and does have physics body on it etc.

 

Something like this:

game.createClass('PhysicsSprite', 'Sprite', {	init: function(texture, x, y) {		this.anchorCenter();		var shape = new game.Rectangle(this.width, this.height);		this.body = new game.Body();		this.body.position.set(x, y);		this.body.addShape(shape);		this.update();	},	addTo: function(container) {		container.addChild(this);		this.body.addTo(game.scene.world);	},	remove: function() {		this.parent.removeChild(this);		this.body.remove();	},	update: function() {		this.position.copy(this.body.position);	}});
Link to comment
Share on other sites

Thank you for the quick reply! Yes, creating such a class is very easy for me.

 

I was making the suggestion as a teacher of students just getting into game programming, heck, even just plain old programming. I like how Panda is structured to eliminate a lot of needlessly abstract code, and instead appeals to the average non-programmer's mind.

 

However, with simple physics, there are a lot of statements that in and of themselves are pretty simple, but collectively take a toll on the beginner.

 

To illustrate what I mean, reading bottom up, the beginner probably assumes that the body should automatically stay the same position as the sprite, and therefore position copy is perhaps confusing at first. Of course, you don't necessarily always want a physics body to follow the sprite, but most of the time, I think gamers are conditioned to expect it.

 

Then the idea of removing the body when you are removing the object. I'm guessing the beginner assumes that the garbage collector should automatically remove the body when the object is "removed." Understanding the keyword "this" is already enough of a mind trip for lots of newbies, so the line this.parent.removeChild(this) is particularly taxing on a beginner's mind. 

 

I mean, I can go on, but I think you get what I'm at least trying to say. Sure, it's my responsibility as a teacher that the students understand these concepts, but the timing of when these concepts are unrolled is more restricted when they are hit by them before they can make a simple platformer, for example.
 
Thanks for acknowledging my thoughts. It is much appreciated. I completely understand if the suggestion is impractical or outside the style of the engine's structure.
Link to comment
Share on other sites

@PixelPicoSean

 

I suppose you're right. Though I'm trying to avoid as best as I can to create "magic" steps or libraries that are outside of what the students can expect outside the class . But I suppose it can't entirely be helped. Thanks for the suggestion, and thank you enpu for your great work on this engine =).

Link to comment
Share on other sites

@oranjosse

 

I get what you are after for, and i'm trying to make Panda Engine code as clean as possible and easy to understand, but also i'm trying to avoid adding things that are "magically" doing something that you really don't know what is happening. Of course small "helper" functions are welcome.

 

Many classes have small static helper functions, so i was thinking something like game.Body.fromSprite, that would return new body, that has rectangle shape with the dimensions of the sprite.

 

You would use it like this, for example:

var sprite = new game.Sprite('panda.png');var body = game.Body.fromSprite(sprite);

What do you think?

 

And just out of interest, where are you teaching game programming? :)

Link to comment
Share on other sites

  • enpu unpinned this topic

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...