YASAFQ
Shri

Gio,

 

Yet another share and fork question (YASAFQ)

 

I am going through the book Physics for Javascript - by Dev Ramtal and Adrian Dobre.

I am redoing ('porting") the examples in their book to run with wade.

I am also incorporating some stuff from the book HTML5 Animation with Javascript - by Keith Peters.

 

My idea was to put all the examples on here via share and fork.

The directory structure is similar to what you would get if you were to download the book source code.

There is a lib directory which holds all lthe common files, and then chapter directories for each chapter.

In each chapter directory,  there is an html file whose name is relevant to the example in the book.

For exmple, chapter 5 contains collisionTest.html, floatingBall.html, forceTest.html which run same named javascript files that perform some example from the book.

 

It seems like share and fork expects one index.html file to run one project/app ?

Do you have any advice on how to proceed ?

I am already through chapter 5 and would like to share the the code with the rest of the

"wadeites / wadeions / waders / wadeans"

 

As always AHYCPIA (any help you can provide is appreciated).

 

cheers,

Shri

All 5 Comments
Gio

Hi Shri

 

Sounds like an excellent idea! It would certainly be useful to a lot of people here (I like the term waders).

 

Share & Fork does expect an index.html as the entry point for your projects. So you have a couple of options in my opinion:

  1. Have a single html file (index.html), but several wade apps in different JavaScript files (collisionTest.js, floatingBall.js, etc). Then have some sort of menu that lets you switch between apps. In fact they don't even need to be separate apps, it could be a single app with several scenes.
     
  2. Just have lots of separate projects, each one with its own index.html file.

 

Number 1 is cooler, number 2 is easier, so it's up to you really.

 

Either way it would be a Great Resource Everyone Appreciates Thoroughly (GREAT).

 

By the way, have you had a chance to try the physics plug-in for wade (for which we're releasing an update today)? I  see you've made lots of wade games using various plug-in's but none with physics. Just wondering why - any feedback would help us improve it, as usual.

 

Thanks

Shri

Gio,

 

Thanks for the advice.

I went with option #1, but just created an index.html file that has links to launch the relevant html example files.

I checked all the links in chrome and they seem to work ok.

I set the project to 'released' so people can look at/use it if they want.

When I get through a couple more chapters, I will go back and fix up the web page.

 

Re: the physics plugin:

When it was first launched, I went through the example, then tried to build a game where cars crash into each other.

The plugin didn't seem to handle high speed collisions very well, and there was an annoying problem where you could drive right through barriers (i.e. if you hit a wall, you could keep pressing the forward button and the car would nudge it's way through, probably because you were now inside the bounding box). I wasn't sure if the problem was on my end, or if the plug-in wasn't mature enough, so rather than figure it out,  I took the cowards way out and just dropped the game  idea.

 

My thoughts were:

1. I would figure out how to integrate box2D if I wanted to do something with complicated physics stuff

2. Roll my own if it wasn't too complicated (i.e. simple elastic collisions)

3. Wait until the next release of the physics plugin and give it another go.

 

So far, I have just been rolling my own (there was some minor physics stuff in ptRaid and pipe dreams). Then I started making a modified version of breakout after seeing foxcode's post with a paddle that rotated in a circle (I almost finished the game, but was never quite happy with it) - this made me realize that I needed a better understanding of the physics handling stuff from a programming perspective.  Which led me to my current undertaking regarding the Physics for Javascript book.This book also covers some 3D webGL stuff in the later chapters which merges nicely with the latest webGL support in wade 1.5.

 

When I finish this book and the code, maybe I'll take another whack at the physics plugin.

 

Sorry for the long winded explanation..

 

cheers,

Shri

Gio

Shri, it looks really good. I'm sure it's definitely going to help a lot of people. Definitely one of the best resources on S&F at the moment. I'll make it a featured project.

 

Here's the link if anyone is reading this thread and is too lazy to look for it on S&F :)

 

Regarding the physics plug-in: admittedly we haven't tried using it for a racing game, but in theory it should work. I don't know if this is what you were doing, but definitely the most common mistake that people do when using physics engines, is setting the positions of objects directly. So for example, the user presses a key and you move the car forward by changing its position coordinates. This would be a problem with any physics engine, including Box2D. What should be done instead, is applying an impulse to the car in the right direction. Setting its velocity may also work depending on the environment (i.e. which forces are acting to the car), but applying an impulse is safer.

 

This should always work, unless the speed of the car is very large and the barrier and the car are very thin, in which case the car could go through the barrier in a single update step (about 16.7ms). With "normal" sizes and velocities this should never happen though. If it does, it's most likely a bug in the physics engine and I'd like to know about it so I can fix it.

 

By "normal" I mean the car and the barrier are more than a couple of pixels big, and the car is moving at less than 20000 pixels per second.

Shri

Gio,

 

Thanks for the physics info, I'll plan on revisiting the game with the new plugin sometime soon.

The speeds and sizes were well within normal parameters, so I will have to look and see what I was doing.

 

One suggestion on share and fork, it would be nice if you could see comments on the project page or on the share and fork home page.

That way, users and developers of projects could have a dialogue directly there. Not sure how hard this would be, just a suggestion.

 

One minor bug on the share and fork download (hopefully its not just me !). When I download a project, I get the zip file, but the file isn't named as a zip file.

That is, the file has no extension. If I rename the file to 'filename.zip', I can then unpack it and everything is there and works as expected, but the extra

rename step seems like a bug (as I said hopefully its not just me).

For example, I just downloaded the 'Spawn Area' Project via the download button.

I get the download file, but it is named Spawn (no extension).

I then rename the file Spawn.zip and unpack it - everything is there.

 

cheers,

Shri

foxcode

Hi Shri

 

We are aware of the zip bug. I need to coax Gio into fixing it as I am busy with other things and he is busy getting high on red bull.

 

I took a look at your physics examples, pretty cool stuff, should be very useful for people coming to WADE..

Post a reply
Add Attachment
Submit Reply
Login to Reply