Jump to content

  • Log In with Google      Sign In   
  • Create Account


Ecoste

Member Since 22 Sep 2011
Offline Last Active Aug 02 2014 08:14 AM

Topics I've Started

Calculating co-ordinates of a line/ray that's increasing in height with a known slo...

02 August 2014 - 05:53 AM

basically in my game I'm firing a line. The line's anchor point is at the very bottom of it, and half of its width.
 
When I fire the line, its rotation gets set to face where we want it to go. Then, with each frame of the game, the height of the line increases and it looks like the player is firing a laser.
 
Here's the code for the initial setting-up to fire and later move the laser. Javascript, using PIXIJS.
 
    function fireLazor(mouseData){
firing = true;
slopeY = (player.y - mouseData.global.y) / (player.x - mouseData.global.x);
slopeX = (player.x - mouseData.global.x) / (player.y - mouseData.global.y);


lazor.rotation = lazorRadians;
lazor.x = player.x;
lazor.y = player.y;
    }
 
Alright, now that the laser is set to go all we need to do is increase its height and it will go in the direction we set it to go.

    if(firing){
lazor.height += lazorAcceleration * DELTA_TIME;
    }
 
Now, that all works fine and dandy. Here's a visual to help.

  BkqvB.jpg
I first wrote some code to basically check the whole path of the laser and see if it hits something, IN ONE FRAME. It works perfectly, but it does so in one frame and the second we fire the laser. And obviously I need for it to check gradually as the laser travels.
 
The problem comes in when we want to collision check the front of the lazor to see if it hit something. We need to figure out what the co-ordinates of the front of the laser are. So, I thought that if we know the slope and the rate at which the height is increasing we can just do(simplified example that would run each frame, except of course without resetting the xtocheck and ytocheck to the player co-ordinates.) 
 
    ticks = lazorAcceleration / slopeY;
    xToCheckForCollsion = player.x;
    yToCheckForCollsion = player.y;
    
    for(i = 0; i < ticks; i++){
    xToCheckForCollsion += 1;
    yToCheckForCollsion += slopeY;
    }
 
I've tried multiplying, diving, both slopeY and slopeX, and other things I could possibly think of. Multiplying by delta time in different spots, ceiling and flooring, just don't know how else to twist it.
 
But, that doesn't work. The collision checks sometimes get ahead of the laser, sometimes they get behind it and etc.
 
Does anybody know how to get the front-coordinate of the laser? Or maybe even do this whole thing another way, I don't know. 
 
Thanks!
 
SOLVED(not rly)
Alright, instead of doing that I just did some geometry and rotated a point.
 

Designing levels...

01 September 2013 - 06:57 AM

Hello, I had an idea for a flash game, basically it's a puzzle game that's tile-based. Each level has a finish that you must get to, but to get to it you need to place tiles that are given to you. I have a prototype going and it's not really a code intensive game, but the problem is creating the puzzles. Like, I only really thought of 1 or 2 levels but I can't come up with anything anymore, how do you do it? I mean, you could always "Borrow" them from other games and then take out some tiles to place, this is the last resort though.


Vector hell!

12 August 2013 - 12:09 PM

Hello, this is the first time using Vectors, and I don't get the math behind them. 

 

Here's my situation(3d Space):

Vector X

Vector Y

 

I want to get a third vector that goes from Vector X to Vector Y, and then I can just scale it myself. Halp.


How much will this cost approx?

06 April 2013 - 08:13 AM

Outsourcing art, I need some assets done for 2D pixel-ish art nothing too complicated. 'Cause right now I'm making a skeleton for a game just don't have any art, so I'm thinking if that gets all done and goes well I could put some GOOD art into it(Not my crappy shit). I honestly have NO idea even approximately how much this will cost. I'm hoping around 300 bucks or so though.

 

-A character and running animation.

-3 Other similar to each other characters

-Background with a foreground, middleground and a background.(Day/Night)

-Tiles/platforms about 4 kinds


AS3 creating new objects.

03 April 2013 - 09:24 AM

Basically I have a simple game. And each 2 seconds a bullet flies out across the screen.

 

//bullet spawner
import flash.utils.Timer;



var myTimer:Timer = new Timer(2000, 1); // 2 second
myTimer.addEventListener(TimerEvent.TIMER, runTimer);
myTimer.start();

function runTimer(e:TimerEvent):void{
	var bulletG:bullet = new bullet(565,Math.random()*400); //Screen is 400 pixels in heigth
	addChild(bulletG);
}
//bullet
package  {
	
	import flash.display.MovieClip;
	import flash.events.Event;
	
	
	public class bullet extends MovieClip {
		
		
		public function bullet(xS:int, yS:int) {
			addEventListener(Event.ENTER_FRAME, update);
			x = xS;
			y = yS
		}
		function update(e:Event){
			x -= 3;
		}
	}
	
}

 

Simple stuff right. Anyway, I wanted to ask if there's a better way of creating bullets. Because right now, if I wanted to create a shit ton of bullets, I could make an array full of bullets and simply spawn them.  That's cool until you get into spawning thousands of bullets, it's not time efficient to write each object yourself, so my question is how would you do it?


PARTNERS