The Team Jackulator Forums
April 25, 2024, 07:29:25 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
   
   Home   Help playlist Arcade Search Media Downloads Login Register  
The Jackulator 9000 Forums
Pages: [1]   Go Down
  Send this topic  |  Print  
This topic has not yet been rated!
You have not rated this topic. Select a rating:
Author Topic: making a game with flash (questions)  (Read 3735 times)
0 Members and 1 Guest are viewing this topic.
CallMeBronco
I'm Mr. Buznik's dick
MEGAMEMBER
Team Jackulator
****
Offline Offline

Location: I don't know
Posts: 2472

I'm dead! Help me out! I'm dyin' here!


Awards
« on: November 18, 2009, 03:13:32 pm »

Im making my first game since highschool with flash now so I dont remember a lot.
What Id like to know is; my game is a maze-like obsticle course thing kind of like AVOIDER. How do you get something to happen when something hits another object and etc.

only thing i remember is it involves hit-test.  T's joker
basiclly theres the "main object" that you move through out the maze, and I want it so you cant touch any other objects. (you have to start over if you hit an object)
Logged

my jackulator tribute video: https://www.youtube.com/watch?v=mtbIpQTjH7M



"Nothing worth having comes without some kind of fight" - Bruce Cockburn



jackulator
... --- ...
Administrator
jackulator.com
******
Offline Offline

Location: Eastwick, Rhode Island
Posts: 10507


"Twenty pushups a day..."


WWW Awards
« Reply #1 on: November 18, 2009, 04:43:17 pm »

haha... wow dude -- if you need help with something that basic you've got a long way to go

there's two different ways to do a hit test:

Code:
if(SOMETHING.hitTest(somethingelse)){
//do something;
}

Code:
if(SOMETHING.hitTest(somethingElse._x, somethingElse._y, true)){
//do something
}

the first one only checks to see if SOMETHING touches even the edge of somethingElse, the second one test to see if SOMETHING touches the center of somethingElse
Logged

CallMeBronco
I'm Mr. Buznik's dick
MEGAMEMBER
Team Jackulator
****
Offline Offline

Location: I don't know
Posts: 2472

I'm dead! Help me out! I'm dyin' here!


Awards
« Reply #2 on: November 18, 2009, 05:31:07 pm »

now that  i think about it I probably couldve figured this out on my own but I wasnt feeling smart today.  lipsrsealed

I read through tutorials but sometimes I need a break from that ya know what I mean? Sometimes I get tired of searching for what I'm looking for and want an answer RIGHT NOW!!  T_Grin1

-thanks
Logged

my jackulator tribute video: https://www.youtube.com/watch?v=mtbIpQTjH7M



"Nothing worth having comes without some kind of fight" - Bruce Cockburn



jackulator
... --- ...
Administrator
jackulator.com
******
Offline Offline

Location: Eastwick, Rhode Island
Posts: 10507


"Twenty pushups a day..."


WWW Awards
« Reply #3 on: November 18, 2009, 06:20:50 pm »

yeah definitely - I wish I'd had someone I could've asked for specific questions back when I was starting out -- often I'd search for hours through forums, and when I'd post questions nobody would respond, or they'd respond with something that didn't help -- once in a while though I'd get a smart guy who'd help me out, but it was the exception to the rule, so most of my knowledge is from pasting bits of code from forums -- other people's sort of related issues -- cutting it up and moving pieces around... testing.. moving shit around... testing... rinse and repeat...
Logged

CallMeBronco
I'm Mr. Buznik's dick
MEGAMEMBER
Team Jackulator
****
Offline Offline

Location: I don't know
Posts: 2472

I'm dead! Help me out! I'm dyin' here!


Awards
« Reply #4 on: November 22, 2009, 04:38:06 pm »

haha... wow dude -- if you need help with something that basic you've got a long way to go

there's two different ways to do a hit test:

Code:
if(SOMETHING.hitTest(somethingelse)){
//do something;
}

Code:
if(SOMETHING.hitTest(somethingElse._x, somethingElse._y, true)){
//do something
}

the first one only checks to see if SOMETHING touches even the edge of somethingElse, the second one test to see if SOMETHING touches the center of somethingElse

Ive been fiddling around and got things working to an extant but what I've hit another block. I need to know how to have it so as soon as the thing touches it happens. right now, if you don't release your mouse button when your over the object it doesn't work & you can pass right through it.

Also, I havent exactly used the above code, is that intended for the main stage or on the movie clip? what else am I missing?

heres an example of the code that "works" so far; (and its written on the main stage of frame 3)

Code:
player.onPress = function() {
    this.startDrag();
};
player.onRelease = function() {
    this.stopDrag();
    if (this.hitTest(black1)) {
    gotoAndStop(2);
    }
};

"player" is the movie clip which is your "moving piece" and "black1" is an obstacle. both of which are movie clips (is that okay?) so when you hit and obstacle your supposed to 'loose' and are sent back to the beginning. get it?
If theres not enough here for you to know what Im talking about I understand, Ican tell you more or whatever
Logged

my jackulator tribute video: https://www.youtube.com/watch?v=mtbIpQTjH7M



"Nothing worth having comes without some kind of fight" - Bruce Cockburn



jackulator
... --- ...
Administrator
jackulator.com
******
Offline Offline

Location: Eastwick, Rhode Island
Posts: 10507


"Twenty pushups a day..."


WWW Awards
« Reply #5 on: November 22, 2009, 08:21:04 pm »

that's because the only time you're checking to see if the object is touching object2 is when you release the mouse

the most common way to check for a hit test is 'onEnterFrame'

you have to be aware though that if you have a bunch of movie clips to do hit tests every frame the SWF will start to get pretty CPU intensive -- lets say you had 10 objects on screen at once, each with an onEnterFrame hit test -- and your SWF had a frame rate of 10fps -- that's 100 checks per second for your SWF -- which it can easily handle, but in my Breakout clone game, because I didn't optimize the code when I wrote it, has probably 100 objects with hit tests, and a frame rate of 60fps, so 6,000 checks per second - which is kind of high if you have a bunch of other code executing -- to the point where when the ball speed is really high sometimes there's noticeable lag -- however I could probably have cut down on this totally if I divided the screen into quadrants, and only did hit tests against the ball for bricks that were in that  quadrant - effectively reducing the ball-brick hit test resource usage by a factor of four

but anyway, just make a new function for onEnterFrame like this:

Code:
player.onEnterFrame = function() {
    if (this.hitTest(black1)) {
    gotoAndStop(2);
    }
};
Logged

jackulator
... --- ...
Administrator
jackulator.com
******
Offline Offline

Location: Eastwick, Rhode Island
Posts: 10507


"Twenty pushups a day..."


WWW Awards
« Reply #6 on: November 22, 2009, 08:33:37 pm »

also - I don't know if you know about this, but I've found it extremely helpful -- you put a trace action on anything you want to test

so if you wanted to check to see if a code for a hit test worked you'd do this:

Code:
someMC.onEnterFrame = function(){
 if (this.hitTest(mc2)){
  trace("someMC touching mc2");
 }
}

I use trace for literally EVERYTHING I am even the least bit uncertain about when I am writing new code

Logged

CallMeBronco
I'm Mr. Buznik's dick
MEGAMEMBER
Team Jackulator
****
Offline Offline

Location: I don't know
Posts: 2472

I'm dead! Help me out! I'm dyin' here!


Awards
« Reply #7 on: December 05, 2009, 04:28:40 pm »

tell me what ya think so far...  cheesy

only 2 levels and you can cheat of course... but don't cheat (cause nobody likes cheaters)

tell me if you have any suggestions.
and of course tell me if its any fun or not  smiley

eventually I want to have a point system and codes


* superAdventureGame.swf (12.05 KB, 550x400 - viewed 204 times.)
Logged

my jackulator tribute video: https://www.youtube.com/watch?v=mtbIpQTjH7M



"Nothing worth having comes without some kind of fight" - Bruce Cockburn



jackulator
... --- ...
Administrator
jackulator.com
******
Offline Offline

Location: Eastwick, Rhode Island
Posts: 10507


"Twenty pushups a day..."


WWW Awards
« Reply #8 on: December 05, 2009, 06:34:32 pm »

that's wicked cool brotha - love it - kind of like operation haha  grin
Logged

CallMeBronco
I'm Mr. Buznik's dick
MEGAMEMBER
Team Jackulator
****
Offline Offline

Location: I don't know
Posts: 2472

I'm dead! Help me out! I'm dyin' here!


Awards
« Reply #9 on: December 09, 2009, 01:19:01 pm »

I condensed the main script down now, :

Code:
player.onEnterFrame = function() {
if(this.hitTest(black1) || this.hitTest(black2) || this.hitTest(black3) || this.hitTest(black4) || this.hitTest(black5) || this.hitTest(spinner) || this.hitTest(block)){
gotoAndStop(2);
}
if(this.hitTest(finishLine)){
gotoAndStop(4);
}
};

as you said, starting from the beginning every time you lose isnt what I want. I want it so every time you hit something basicly you just have to start that level over.
I thought maybe I could have a code on frame 2 that somehow saves information about where you are in the game so when you press the button there your sent to where you left off.
Or if you know a way to have the blue ball just go back to the starting position that would be fine too.  smiley
or what you said before about just making 1 big map level with checks points
or all of the above   or something else, or something completely different T_grin7
Ill tackle more complex obstices like other moving objects later  lipsrsealed
Logged

my jackulator tribute video: https://www.youtube.com/watch?v=mtbIpQTjH7M



"Nothing worth having comes without some kind of fight" - Bruce Cockburn



Pages: [1]   Go Up
  Send this topic  |  Print  
 
Jump to:  



Powered by MySQL Powered by PHP Powered by SMF 1.1.5 | SMF © 2006-2008, Simple Machines LLC | Sitemap Valid XHTML 1.0! Valid CSS!
Page created in 0.568 seconds with 21 queries.