parkm / oldbpm

A JavaScript game where you shoot at bubbles.
0 stars 1 forks source link

Texture and image placement in res.js #14

Closed parkm closed 10 years ago

parkm commented 10 years ago

https://github.com/despondentdonkey/bpm/commit/90cff647a65d4f80e8324fda4884a5bfda2d1e16 this commit has added automatic texture creation after an image has been loaded. So when you load an image using the loadImages function like this:

loadImages(this.loader, 'res/', true, {
    bubble: 'bubble.png'
});

it will create: res.bubbleImg res.bubbleTex

I'm wondering if it should stay this way or if we should do something like:

res.textures.bubble res.images.bubble

This way seems to have a better structure but the other way is faster to type. So which way should it be?

dgpt commented 10 years ago

Looks good. I prefer res.images.bubble because organization - it looks less sloppy. BUT, are we ever going to need to reference the texture or image? (I actually don't really know the difference)

On Fri, May 2, 2014 at 3:16 PM, Parker Miller notifications@github.comwrote:

90cff64https://github.com/despondentdonkey/bpm/commit/90cff647a65d4f80e8324fda4884a5bfda2d1e16this commit has added automatic texture creation after an image has been loaded. So when you load an image using the loadImages function like this:

loadImages(this.loader, 'res/', true, { bubble: 'bubble.png' });

it will create: res.bubbleImg res.bubbleTex

I'm wondering if it should stay this way or if we should do something like:

res.textures.bubble res.images.bubble

This way seems to have a better structure but the other way is faster to type.

— Reply to this email directly or view it on GitHubhttps://github.com/despondentdonkey/bpm/issues/14 .

parkm commented 10 years ago

Everything in PIXI uses a Texture which is created from an Image. I'm thinking that we're only going to need textures.

But what's cool is that you can also pass a Canvas element to the Texture. So we use 2D canvas to render something as a picture and then create a Texture out of it for PIXI to use. In order to do this though we're going to need the images.

Oh yeah we can actually just get the image from the Texture. So nevermind about images. myTexture.source

But what about sounds?

res.textures.bubble res.sounds.bubblePop

Should we still use this structure?

dgpt commented 10 years ago

Why would you need to use a 2D Canvas to render something as a picture then create a texture for Pixi?

I think we should still group it, but shorten the names to something like this: res.gfx.bubble res.sfx.bubblePop

On Fri, May 2, 2014 at 3:29 PM, Parker Miller notifications@github.comwrote:

Everything in PIXI uses a Texture which is created from an Image. I'm thinking that we're only going to need textures.

But what's cool is that you can also pass a Canvas element to the Texture. So we use 2D canvas to render something as a picture and then create a Texture out of it for PIXI to use. In order to do this though we're going to need the images.

Oh yeah we can actually just get the image from the Texture. So nevermind about images. myTexture.source

But what about sounds?

res.textures.bubble res.sounds.bubblePop

Should we still use this structure?

— Reply to this email directly or view it on GitHubhttps://github.com/despondentdonkey/bpm/issues/14#issuecomment-42081072 .

parkm commented 10 years ago

Remember how we cached images and text? So if I have to render a billion tiles I can cache it into one image and just render an image rather than having to render each tile. This works great for static stuff.

Yeah that'll be better. I'm going to change 'gfx' to 'tex' though.