Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by yoschi

Hey everyone

I've just gotten into Impact and I'm looking to create a game, not with images but rather with lines and shapes. I was looking for a way to draw a simple cube using 4 coordinates, with the possibility to fill it and have it react to collisions. I apologize if this is overly simple but I can't find it in the help section, maybe someone could give me a head start?

I want to be able to stretch/distort it and modifiy the cube later, like adding verticies until it creates an outline for a character.

Thanks for any input!

1 decade ago by Hareesun

A cube is 3D. A rectangle/square is 2D. :P

https://developer.mozilla.org/en/Canvas_tutorial/Drawing_shapes

1 decade ago by yoschi

haha, true! thanks for the info. I thought there might be a specific impact function I would have to use instead of the basic html5 ones.

1 decade ago by Hareesun

Nah. It’s all canvas. You can of course use Impact’s pos.x and pos.y stuff to get better control, but you’ll also need to use ig.system.context instead of the regular one. (Or something like that) It’s all very possible. I’ve toyed with making a plugin to make drawing shapes a little more intuitive. Interested?

1 decade ago by yoschi

Actually yes, that would be awesome. what were you planning?
I'm still wondering about the collisions when drawing shapes with base html5 but I guess I need to get more into the framework to get a better sense of what's possible, It's been a while since I've programmed a game.

1 decade ago by Hareesun

Probably just something that gives you ig.rect(x, y, width, height, [color]); and the other basic shapes. I’ll look into it.

You won’t be able to polygonal collision with Impact. But you can get rectangular for sure. As the collision is determined by the size and setting of the entity. For instance…
ctx.fillRect(this.pos.x, this.pos.y, this.size.x, this.size.y);

will create a rectangle the position of the entity and the size of the entity.

You may need to use some other variables to get settings right.

For instance, in an old prototype of mine I have a draw method of this on an entity…
    draw: function() {
      var ctx = ig.system.context;
      var s = ig.system.scale;
      var x = this.pos.x * s - ig.game.screen.x * s;
      var y = this.pos.y * s - ig.game.screen.y * s;
      var sizeX = this.size.x * s;
      var sizeY = this.size.y * s;
      ctx.save();
        ctx.fillStyle = this.color;
        ctx.fillRect(x,y,sizeX,sizeY);
        this.parent();
      ctx.restore();
    },

Experiment, I’m sure you’ll find what works and how to avoid breaking it. :)

1 decade ago by MikeL

@ Hareesun: I motion that you post at least one of the 20+ games that you are working on before creating any official plugin? Anyone second?

1 decade ago by Hareesun

Hahahahaha. There are actually 19 not including ones still only on paper. :P (38 including)

I will one day though. It’s just picking the title to commit some serious time to that’s the problem. Doesn’t help that I’m doing some pretty mega stuff for the 2012 Olympics for my day-job. One of these days I’ll go on holiday and finish building a game. :P

1 decade ago by MikeL

Oh come on. There will be another one in 5 or so years. Why all the fuss? :)

One a serious note, working on 2012 Olympics stuff is very cool. Good for you. My day job has mostly hampered my game plans for the last several months. So it's understandable.

After Summer 2012 though, there are no more excuses. And forget about the Winter Olympics. That is unless you are making an HTML5 Winter Olympics game (which would be very cool. There was one for the home computer years ago that was a blast).

1 decade ago by yoschi

@ Hareesun: I guess Rectangular and Circle Collision will have to do until Impact gets polygonal collision if ever. Feels good to know what I'm doing now will be playable in any browser in the future. For some reason I can't Imagine going back to classic c coding ever again.
I didn't know you were planning that many things at once, that is kind of like what I do, just that I rarely finish it. xD gotta focus!
It's pretty cool you're doing something for the Olympics :)
@ MikeL : I had Winter Games for the Amiga... damn that was a though beast. I never really had fun playing it as a kid but still played it anyway because I thought I might understand why it existed in the first place. I found out it existed to break my Game Controller lol
Page 1 of 1
« first « previous next › last »