Author Topic: Stages and Collision  (Read 17659 times)

0 Members and 2 Guests are viewing this topic.

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: Stages and Collision
« Reply #30 on: November 17, 2011, 08:31:16 pm »
You can learn it... but you cant? I think bullets are pretty easy, personally :P

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: Stages and Collision
« Reply #31 on: November 17, 2011, 08:35:28 pm »
Well im the softmore at my school who has been programming in Basic for the past few years and placing games onto other peoples calcs, yet, none of my games have bullets...
But back to the topic... (Help with Bullets now...)
« Last Edit: November 17, 2011, 08:38:35 pm by hellninjas »

Offline parserp

  • Hero Extraordinaire
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1455
  • Rating: +88/-7
  • The King Has Returned
    • View Profile
Re: Stages and Collision
« Reply #32 on: November 17, 2011, 09:01:27 pm »
ok, so you need some help?
I've never done this before, so here goes:
have a var to see which way player/gun is facing (so bullet goes in right direction)
when you press a key, a variable is created (direction) and the bullet is drawn at the gun's X,Y coords.
then, every loop, the bullet's position is added/subtracted from depending on which way gun is facing- thus creating the illusion it is being "shot"
Ah! it's 7:00! I gtg! bbl!

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: Stages and Collision
« Reply #33 on: November 17, 2011, 09:04:29 pm »
And have a variable to space the bullets if you have more than one at a time :)
I have 2 vars that check the bullet. The first one is turned on when the bullet is fired. I have that set the coords and direction. The second one is activated (and first deactivated) afterward which, if 1, makes the bullet move in the direction. Thats my way. :P

Coded example coming up :P

For a simple 1 bullet, here is what I would use. I actually could just use one bullet check var, that would be easier :P

Repeat getkey(15)
If getkey(9)
!If F
. F is a bullet check. It equals 1  when the bullet is being fired, 0 when it isnt.

X->A
Y->B
R->C
.R is if the player is facing left or right (right is 1, left is 0 here)
.Save that so the bullet wont go backwards :P
.X and Y are the player's coordnates, thats where the bullet starts
1->F
.When F is 1, that makes it so it wont go through this again.
End
End
If F
.So if F is 1, that means to start moving the bullet.
If C
A++
Else
A--
End
.That checks if it is going left or right.
PtOn(A,B,Pic1)
.Put it on the screen with whatever pic your bullet is
End
If A>96 or (A+8<0)
.If the bullet is outside the screen
0->F
.When F is zero, the bullet stops moving and another bullet can be shot
99->A
.Putting the Coords outside of the screen so it wont interfere
End
End

I dont think I'm forgetting anything other than bullet to enemy collision detects.
Since I didn't put a variable for bullet spacing, this code will make your bullets fire really fast if you're at the edge of the screen, however.
« Last Edit: November 17, 2011, 09:19:09 pm by epic7 »

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: Stages and Collision
« Reply #34 on: November 18, 2011, 02:31:55 pm »
How would I fire multiple bullets? Like a space shooter or like Shmup?

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: Stages and Collision
« Reply #35 on: November 18, 2011, 03:45:43 pm »
Here:

Pick a variable for your for loops. I used V.
Pick L1, L2, L3 etc. I used L5.

Im taking this from my game

.Outside the main loop
For(V,0,5)
.I put 5 there to say what the max possible bullets on the screen would be.
0->{V*4+L5}
End
.That sets the bullet check to zero.
25->S->T
.S and T will be what spaces the bullets. T will gain 1 every time the loop finishes and when it reaches S, which is set to 25, a bullet will be ready to be fired.
Repeat getkey(15)
.Inside the main loop somewhere
If getKey(54)
For(V,0,5)
If T=S
.Checks if T=S so that the bullets are spaced out
!If {V*4+L5}
.If the bullet check is 0, set it to 1
1->{V*4+L5}
.Turn T back to 0 and it will have to go back up to 25 (T) to fire again
0->T
.Exits this loop now since we already have our bullet
Goto X
End
End
End
End
Lbl X
.Other stuff
For(V,0,5)
If {V*4+L5}=1
.If bullet check = 1
.Set the coordnates of the player to the bullet
X->{V*4+L5+1}
Y->{V*4+L5+2}
.Display
Pt-On({V*4+L5+1},{V*4+L5+2},Pic2
.Turn on the bullet check to 2 now.
2->{V*4+L5}
.You should have a variable that tells if the character is left or right. Save that to the bullet like here
R->{V*4+L5+3}
End
End
For(V,0,I)
If {V*4+L5}=2
.Checks if the bullet check is 2...
If {V*4+L5+3}
.If facing right..
{V*4+L5+1}+2->{V*4+L5+1}
Else
.If its not,
{V*4+L5+1}-2->{V*4+L5+1}
End
.Display
Pt-On({V*4+L5+1},{V*4+L5+2},Pic2)
End
End
For(V,0,I)
If {V*4+L5+1}>90
.If the bullet is off the screen (Works for both left and right side)
.Set the bullet checksback to zero and put the coordnates off the screen to not interfere
0->{V*4+L5}+100->{V*5+L5+1}->{V*5+L5+2}
Return
End
End
.Make T move up to S for the bullet spacing
If T<S
T++
End

Thats for just the bullets. I also have collision detects if you need.
To clear up the bullet check, this is what it does.

When
{V*5+L5}=0
That means a new bullet is ready to be shot

When
{V*4+L5}=1
That means the bullet's coordinates and left/right need to be set.

When
{V*4+L5}=2
That means to move the bullet.


Whoo... Done! :P
« Last Edit: November 18, 2011, 04:20:54 pm by epic7 »

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: Stages and Collision
« Reply #36 on: November 18, 2011, 08:28:11 pm »
JESUS!! There's alot more to it than I thought! Thanks!
*Takes Notes*
This will be helpful for future games...

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: Stages and Collision
« Reply #37 on: November 18, 2011, 09:17:28 pm »
Its probably enough to be its own tutorial.

In fact, I just made it one.
Why not? :P
« Last Edit: November 19, 2011, 01:16:59 pm by epic7 »

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: Stages and Collision
« Reply #38 on: November 19, 2011, 03:06:57 pm »
And yes, could you help me a bit with stage collision?
Lets say if I had a stage like on stage one for "Swords" how would I make my character stand or land on the platforms?

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: Stages and Collision
« Reply #39 on: November 19, 2011, 03:08:48 pm »
The easy way would just to do a pxl-test.
« Last Edit: November 19, 2011, 03:12:54 pm by epic7 »

Offline saintrunner

  • Custom Spriter: You ask it! I'll Make it!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1787
  • Rating: +115/-11
  • Flogging Molly
    • View Profile
    • Jonny K Music
Re: Stages and Collision
« Reply #40 on: November 19, 2011, 03:10:18 pm »
*pxl-test*
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: Stages and Collision
« Reply #41 on: November 19, 2011, 03:12:21 pm »
Whoops. :P
* epic7 edits previous post
« Last Edit: November 19, 2011, 03:12:44 pm by epic7 »

Offline saintrunner

  • Custom Spriter: You ask it! I'll Make it!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1787
  • Rating: +115/-11
  • Flogging Molly
    • View Profile
    • Jonny K Music
Re: Stages and Collision
« Reply #42 on: November 19, 2011, 03:15:28 pm »
mhmm! and to hellninjas, just pxl-test the feet of your characters sprite. so when you jump, it first checks to see if your feet are touching a line then it jumps and falls till you touch a line again, here is a game I started a while ago that uses this, tell me if this isn't what your looking for!

edit: wrong screenie one sec

edited:here is the right one! also I can show you an easier but less advanced way for bullets
« Last Edit: November 19, 2011, 03:19:54 pm by saintrunner »
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: Stages and Collision
« Reply #43 on: November 19, 2011, 03:26:17 pm »
If pxl-Test(x,y+8) or (pxl-Test(x+8,y+8))

I think that will check, right?
I need to start using pxl tests :P
I'll use them if I finish that jump game
« Last Edit: November 19, 2011, 03:27:21 pm by epic7 »

Offline saintrunner

  • Custom Spriter: You ask it! I'll Make it!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1787
  • Rating: +115/-11
  • Flogging Molly
    • View Profile
    • Jonny K Music
Re: Stages and Collision
« Reply #44 on: November 19, 2011, 03:40:02 pm »
yeah that will work, but you also need the ( at the beginning, but I think that was just a typo. lol
and then you need to tell it to add to 'y' if it is not equal 1
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES: