Jump to content

Photo

New Game: Air Hockey

new game air hockey development

56 replies to this topic

#26 Random Terrain OFFLINE  

Random Terrain

    Visual batari Basic User

  • 28,013 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Sat Jul 29, 2017 8:31 PM

. . . although I'm still using the older BB, I think. Not 100% sure.


There's a good way to know for sure:
 

randomterrain.com/atari-2600-memories-batari-basic-commands.html#gettingstarted



#27 8-bit_d-boy OFFLINE  

8-bit_d-boy

    Space Invader

  • Topic Starter
  • 46 posts

Posted Sat Jul 29, 2017 10:33 PM

Looking at the dates of the executables, it seems I am.

 

Got some headway with the collision code, here's the source so far. The new code is only in the red paddle.

 

 

EDIT:

Fixed the ball clipping thru the non-moving paddle, but the issue still persists where the ball will clip through the paddle and receive its impulse if the paddle is moving in the same direction as the ball.

Attached the updated code.

 

Here's the collsion part:

rem ------------------------

	rem        collision

	rem ------------------------

	rem ----RED PADDLE COLLISION----
	if !collision(player0,ball) || bCollsn then goto _skip_P0_B_col
		AUDF1 = 4 - bvy
		AUDV1 = 15
		bCollsn = 1
		tmp = 0
		
		if ballx > player0x - 3 && ballx < player0x + 7 then xClip = 1
		if bally > player0y - 3 && bally < player0y + 7 then yClip = 1
		
		if xClip && yClip then xyClip = 1 
		
			
_skip_ball_knock_back
		rem if the player isnt moving, reverse movement, otherwise copy its direction
		if bMoveLf then bMoveRt = 1 : bMoveLf = 0 : goto _skip_to_b_p0_vmotn
		if bMoveRt then bMoveRt = 0 : bMoveLf = 1
_skip_to_b_p0_vmotn
		if bMoveUp then bMoveUp = 0 : bMoveDn = 1 : goto _skip_b_rev_p0
		if bMoveDn then bMoveUp = 1 : bMoveDn = 0
_skip_b_rev_p0		

		if p0_x = 0 then goto _skip_to_p0_yCol
			if bMoveRt && p0_mv_Rt then goto _skip_to_p0_yCol
			if bMoveLf && p0_mv_Lf then goto _skip_to_p0_yCol
				bMoveLf = p0_mv_Lf : bMoveRt = p0_mv_Rt 
_skip_to_p0_yCol
		if p0_y = 0 then goto _skip_to_bVel_accumulation
			if bMoveUp && p0_mv_Up then goto _skip_to_bVel_accumulation
			if bMoveDn && p0_mv_Dn then goto _skip_to_bVel_accumulation
				bMoveUp = p0_mv_Up : bMoveDn = p0_mv_Dn 
		;if temp6 > 0 then goto _skip_b_rev_p0
_skip_to_bVel_accumulation
		bvx = bvx + p0_x + p0_x
		bvy = bvy + p0_y + p0_y

Attached Files


Edited by 8-bit_d-boy, Mon Jul 31, 2017 12:23 PM.


#28 8-bit_d-boy OFFLINE  

8-bit_d-boy

    Space Invader

  • Topic Starter
  • 46 posts

Posted Mon Jul 31, 2017 7:13 PM

I still can't figure out for the life of me why the ball still clips through the paddle when they're both moving the same direction, so somehow it's skipping the goto statements.

Also for some reason, changing this:


		if p0_x = 0 then goto _skip_to_p0_yCol
			if bMoveRt && p0_mv_Rt then goto _skip_to_p0_yCol
			if bMoveLf && p0_mv_Lf then goto _skip_to_p0_yCol
				bMoveLf = p0_mv_Lf : bMoveRt = p0_mv_Rt 
_skip_to_p0_yCol
		if p0_y = 0 then goto _skip_to_bVel_accumulation
			if bMoveUp && p0_mv_Up then goto _skip_to_bVel_accumulation
			if bMoveDn && p0_mv_Dn then goto _skip_to_bVel_accumulation
				bMoveUp = p0_mv_Up : bMoveDn = p0_mv_Dn 

To this:

                if p0_mv_Lf = 0  && p0_mv_Rt = 0 then goto _skip_to_p0_yCol
			if bMoveRt && p0_mv_Rt then goto _skip_to_p0_yCol
			if bMoveLf && p0_mv_Lf then goto _skip_to_p0_yCol
				bMoveLf = p0_mv_Lf : bMoveRt = p0_mv_Rt 
_skip_to_p0_yCol
		if p0_mv_Up = 0 && p0_mv_Dn = 0 then goto _skip_to_bVel_accumulation
			if bMoveUp && p0_mv_Up then goto _skip_to_bVel_accumulation
			if bMoveDn && p0_mv_Dn then goto _skip_to_bVel_accumulation
				bMoveUp = p0_mv_Up : bMoveDn = p0_mv_Dn 

It won't compile due to some sort of syntax error.
Wut?

Attached Files


Edited by 8-bit_d-boy, Mon Jul 31, 2017 7:51 PM.


#29 Random Terrain OFFLINE  

Random Terrain

    Visual batari Basic User

  • 28,013 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Mon Jul 31, 2017 7:22 PM

If that is the exact code, looks like the first line isn't indented.



#30 8-bit_d-boy OFFLINE  

8-bit_d-boy

    Space Invader

  • Topic Starter
  • 46 posts

Posted Mon Jul 31, 2017 7:48 PM

If that is the exact code, looks like the first line isn't indented.

It's actually indented in the code, I just copied it from the indent on.

Updated the post and added source file.



#31 Random Terrain OFFLINE  

Random Terrain

    Visual batari Basic User

  • 28,013 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Mon Jul 31, 2017 8:10 PM

I see one problem right away. You are using NOT with OR in the same ifthen. I always use this chart because I can't remember what is and isn't allowed:

 

randomterrain.com/atari-2600-memories-batari-basic-commands.html#if

 

if_chart.png



#32 Random Terrain OFFLINE  

Random Terrain

    Visual batari Basic User

  • 28,013 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Mon Jul 31, 2017 9:12 PM

Found another problem. Since you are using def with bit operations without using names that point out that they are bits instead of regular variables, it's impossible to know what is going on.

 

Here's an example:

 

        if p0_mv_Lf = 0  && p0_mv_Rt = 0 then goto _skip_to_p0_yCol

 

People looking at your code won't know that p0_mv_Lf and p0_mv_Rt are using bits instead of variables without memorizing all of your DEFs and nobody is going to have the time to do that. Using something like _Bit_p0_mv_Lf  and _Bit_p0_mv_Rt would let people know that they are bits. And knowing that, we could tell you that bit operations do not use an equal sign in ifthen statements:

 

randomterrain.com/atari-2600-memories-batari-basic-commands.html#bit

 

 

You should be doing this instead:

 

   if !p0_mv_Lf && !p0_mv_Rt then goto _skip_to_p0_yCol


#33 8-bit_d-boy OFFLINE  

8-bit_d-boy

    Space Invader

  • Topic Starter
  • 46 posts

Posted Tue Aug 1, 2017 12:49 AM


 

 

Found another problem. Since you are using def with bit operations without using names that point out that they are bits instead of regular variables, it's impossible to know what is going on.

 

Here's an example:

 

        if p0_mv_Lf = 0  && p0_mv_Rt = 0 then goto _skip_to_p0_yCol

 

People looking at your code won't know that p0_mv_Lf and p0_mv_Rt are using bits instead of variables without memorizing all of your DEFs and nobody is going to have the time to do that. Using something like _Bit_p0_mv_Lf  and _Bit_p0_mv_Rt would let people know that they are bits. And knowing that, we could tell you that bit operations do not use an equal sign in if…then statements:

 

randomterrain.com/atari-2600-memories-batari-basic-commands.html#bit

 

Good to know, I'll have to update that.

 

 

You should be doing this instead:

 

   if !p0_mv_Lf && !p0_mv_Rt then goto _skip_to_p0_yCol

Changed it to that, still won't compile :(


Edited by 8-bit_d-boy, Tue Aug 1, 2017 12:52 AM.


#34 Random Terrain OFFLINE  

Random Terrain

    Visual batari Basic User

  • 28,013 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Tue Aug 1, 2017 1:20 AM

Changed it to that, still won't compile :(


See if this works:
 

Attached File  airhockey_2017y_08m_01d_0316t.bas   12.26KB   11 downloads



#35 8-bit_d-boy OFFLINE  

8-bit_d-boy

    Space Invader

  • Topic Starter
  • 46 posts

Posted Tue Aug 1, 2017 11:39 AM

Yours seems to compile, but when I copy your collision code into mine, it doesn't, even after changing xy_Clip back to xyClip.

 

What all did you change?

 

Also I can keep the if lines as:

if p0_x = 0 then...

as p0_x would be zero if the joystick hasn't been moved left or right. Same for p0_y. I was just seeing if it made any difference with the clipping, but it doesn't :\

 

Could it be due to these lines?

			if bMoveRt && p0_mv_Rt then goto _skip_to_p0_yCol
			if bMoveLf && p0_mv_Lf then goto _skip_to_p0_yCol

and

			if bMoveUp && p0_mv_Up then goto _skip_to_bVel_accumulation
			if bMoveDn && p0_mv_Dn then goto _skip_to_bVel_accumulation

Edited by 8-bit_d-boy, Tue Aug 1, 2017 6:14 PM.


#36 Random Terrain OFFLINE  

Random Terrain

    Visual batari Basic User

  • 28,013 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Tue Aug 1, 2017 8:30 PM

I changed this:
 

   def xClip = boolean{0}
   def yClip = boolean{1}
   def xyClip = boolean{2}
   def bMoveRt = boolean{3}
   def bMoveLf = boolean{4}
   def bMoveUp = boolean{5}
   def bMoveDn = boolean{6}
   def bCollsn = boolean{7}


   p = 0
   dim boolean1 = p
   def p0_mv_Lf = boolean1{0}
   def p0_mv_Rt = boolean1{1}
   def p0_mv_Up = boolean1{2}
   def p0_mv_Dn = boolean1{3}
   def p1_mv_Lf = boolean1{4}
   def p1_mv_Rt = boolean1{5}
   def p1_mv_Up = boolean1{6}
   def p1_mv_Dn = boolean1{7}

 
to this:
 

   def xClip=boolean{0}
   def yClip=boolean{1}
   def xy_Clip=boolean{2}
   def bMoveRt=boolean{3}
   def bMoveLf=boolean{4}
   def bMoveUp=boolean{5}
   def bMoveDn=boolean{6}
   def bCollsn=boolean{7}


   p = 0
   dim boolean1 = p
   def p0_mv_Lf=boolean1{0}
   def p0_mv_Rt=boolean1{1}
   def p0_mv_Up=boolean1{2}
   def p0_mv_Dn=boolean1{3}
   def p1_mv_Lf=boolean1{4}
   def p1_mv_Rt=boolean1{5}
   def p1_mv_Up=boolean1{6}
   def p1_mv_Dn=boolean1{7}

 
You can't use yClip and xyClip since xyClip contains the string yClip. The program won't compile. I also got rid of the spaces around the equals sign since def won't work correctly with spaces around the equals sign for some strange reason.
 
 
I changed this:
 

   if !collision(player0,ball) || bCollsn then goto _skip_P0_B_col

 
to this:
 

   if !collision(player0,ball) then goto _skip_P0_B_col
   if bCollsn then goto _skip_P0_B_col

 
You can't use NOT with OR.
 
 
I changed this:
 

   if xClip && yClip then xyClip = 1

 
to this:
 

   if xClip && yClip then xy_Clip = 1 

 

Strings used with def must be different from each other or you will get strange errors. For example, if you used _PullMyLeg, you couldn't use Pull or My or Leg as def strings.
 

 
I changed this:
 

   if p0_mv_Lf = 0  && p0_mv_Rt = 0 then goto _skip_to_p0_yCol

 
to this:
 

   if !p0_mv_Lf && !p0_mv_Rt then goto _skip_to_p0_yCol

 
Bit operations do not use an equal sign in if…then statements.
 
 
I changed this:
 

   if p0_mv_Up = 0 && p0_mv_Dn = 0 then goto _skip_to_bVel_accumulation

 
to this:
 

   if !p0_mv_Up && !p0_mv_Dn then goto _skip_to_bVel_accumulation

 
Bit operations do not use an equal sign in if…then statements.
 
 
I changed this:
 

   if !collision(player1,ball) || bCollsn then goto _skip_P1_B_col

 
to this:
 

   if !collision(player1,ball) then goto _skip_P1_B_col
   if bCollsn then goto _skip_P1_B_col

 
You can't use NOT with OR.



#37 8-bit_d-boy OFFLINE  

8-bit_d-boy

    Space Invader

  • Topic Starter
  • 46 posts

Posted Tue Aug 1, 2017 9:57 PM

Thanks for all your help so far, man! I'm learning a lot here.



#38 Neuronic OFFLINE  

Neuronic

    Space Invader

  • 49 posts
  • Location:Cincinnati, Ohio

Posted Thu Aug 3, 2017 5:48 PM

Thanks for all your help so far, man! I'm learning a lot here.

 

Me too! :)



#39 8-bit_d-boy OFFLINE  

8-bit_d-boy

    Space Invader

  • Topic Starter
  • 46 posts

Posted Thu Aug 3, 2017 6:30 PM

So I have 540 bytes left for my program to not only fix the clipping issue, but also implement collisions that move the ball in more directions than just the reverse of what it was doing, not to mention copy that over to player1.

 

I REALLY wanna fix the clipping issue as it's kind of a game-breaker in some regards. I think I'd be able to implement the other things though.

 

 

EDIT:

I started working on some code to move the ball back to where it would hit the paddle between its last position and current position, and I'm trying to figure out how to move it so that it's only touching the paddle, and I think this could  not only prevent the clipping issue, but also aid in determining what direction to ricochet in.

 

I need to figure out what formula I can use to determine  where to put the ball based on:

 

Ball's direction

Ball's current position

Ball's previous position

Ball's size(4 by 4)

Player's position

Player's size(8 by 8 )

Here's what I have so far, and no, it doesn't work right, but it's a start I guess.:

; BEGIN CONTEXT
rem ----RED PADDLE COLLISION----
	if !collision(player0,ball) then goto _skip_P0_B_col
 	if bCollsn then goto _skip_P0_B_col

	AUDF1 = 4 - bvy
	AUDV1 = 15
	bCollsn = 1
	tmp = 0
	
	if ballx > player0x - 3 && ballx < player0x + 7 then xClip = 1
	if bally > player0y - 3 && bally < player0y + 7 then yClip = 1
	
	if xClip && yClip then xy_Clip = 1 
	temp6 = 0 : temp5 = 0
; END CONTEXT
; HERE'S THE KNOCKBACK CODE
	if !xClip then _skip_offset_horizontal
		temp6 = ballx - player0x
		if !bMoveRt then _skip_offset_lf
			temp5 = temp6 + 4
			ballx = ballx - temp5
_skip_offset_lf
		if !bMoveLf then _skip_offset_horizontal
			temp5 = 8 - temp6
			ballx = ballx + temp5
 		temp6 = 0 : temp5 = 0
_skip_offset_horizontal
	if !yClip then _skip_offset_vertical
		temp6 = ballx - player0y
		if !bMoveUp then _skip_offset_up
			temp5 = temp6 + 4
			bally = bally - temp5
_skip_offset_up
		if !bMoveDn then _skip_offset_vertical
			temp5 = 8 - temp6
			bally = bally + temp5
_skip_offset_vertical
_skip_ball_knock_back

I've included the game source as well.

Attached Files


Edited by 8-bit_d-boy, Thu Aug 3, 2017 8:23 PM.


#40 Random Terrain OFFLINE  

Random Terrain

    Visual batari Basic User

  • 28,013 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Sat Aug 5, 2017 2:29 AM

Just letting you know that I'm not ignoring you. I had an operation on my right leg last week and I'm trying to finish up some other things on my computer while I don't have to be in bed. I have to see a doctor on Monday about my pancreas, then I get an operation on my left leg on Tuesday (if the gut doctor doesn't put me in the hospital), so I'm probably going to be useless for most of next week. I'll be able to post simple things from a smartphone while I'm in bed, but I won't be able to work on programs or anything like that.



#41 8-bit_d-boy OFFLINE  

8-bit_d-boy

    Space Invader

  • Topic Starter
  • 46 posts

Posted Sat Aug 5, 2017 9:02 AM

Just letting you know that I'm not ignoring you. I had an operation on my right leg last week and I'm trying to finish up some other things on my computer while I don't have to be in bed. I have to see a doctor on Monday about my pancreas, then I get an operation on my left leg on Tuesday (if the gut doctor doesn't put me in the hospital), so I'm probably going to be useless for most of next week. I'll be able to post simple things from a smartphone while I'm in bed, but I won't be able to work on programs or anything like that.

It's cool dude, I was asking help from anyone who could and was not expecting you to feel obligated to helping me.

Thanks for all your help so far and good luck with your pancreas.


Edited by 8-bit_d-boy, Sat Aug 5, 2017 9:05 AM.


#42 accousticguitar OFFLINE  

accousticguitar

    Quadrunner

  • 6,557 posts
  • Sherlock made it to 15 before he left us.
  • Location:Idaho

Posted Sat Aug 5, 2017 9:38 AM

Just letting you know that I'm not ignoring you. I had an operation on my right leg last week and I'm trying to finish up some other things on my computer while I don't have to be in bed. I have to see a doctor on Monday about my pancreas, then I get an operation on my left leg on Tuesday (if the gut doctor doesn't put me in the hospital), so I'm probably going to be useless for most of next week. I'll be able to post simple things from a smartphone while I'm in bed, but I won't be able to work on programs or anything like that.

Wow, I hope you feel better soon.

#43 8-bit_d-boy OFFLINE  

8-bit_d-boy

    Space Invader

  • Topic Starter
  • 46 posts

Posted Sun Aug 6, 2017 12:10 PM

More compilation issues (yayyy).

 

So in order to move the ball up until it collides with the paddle and no more, I modified this:

	if scoring <> 61 then _skip_ball_movment
		pbx = ballx 
		if bMoveLf then ballx = ballx - bvx
		if bMoveRt then ballx = ballx + bvx
		pby = bally
		if bMoveUp then bally = bally - bvy
		if bMoveDn then bally = bally + bvy

_skip_ball_movment

to this:


	temp6 = bvx + bvy
	if bvx > bvy then temp5 = bvx / bvy : temp4 = bvy else temp5 = bvy / bvx : temp4 = bvx
	
	if scoring <> 61 then _skip_ball_movment
		pbx = ballx 
		for temp3 = 0 to temp4
			temp2 = temp3 // temp4
			if temp2 = 0 then if bvx > bvy then bally = bally + 1 : if bvy > bvx then ballx = ballx + 1
			if temp2 <> 0 then if bvx > bvy then ballx = ballx + 1 : if bvy > bvx then bally = bally + 1
			if collision(player0, ball) || collision(player1, ball) then temp3 = temp4
		next
		if bMoveLf then ballx = ballx - bvx
		if bMoveRt then ballx = ballx + bvx
		pby = bally
		if bMoveUp then bally = bally - bvy
		if bMoveDn then bally = bally + bvy

_skip_ball_movment

and it won't compile now, stating:

--- Unresolved Symbol List
div8                     0000 ????         (R )

      425 bytes of ROM space left

C:\Users\chris\atari\airHockey\air hockey\airhockey.bas.asm (3435): error: Branch out of range (138 bytes).

Fatal assembly error: Source is not resolvable.
Errors were encountered during assembly.

Progress, I guess.



#44 Random Terrain OFFLINE  

Random Terrain

    Visual batari Basic User

  • 28,013 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Sun Aug 6, 2017 12:24 PM

Why are you using // instead of /?

 

http://www.randomter...s.html#division



#45 kdgarris OFFLINE  

kdgarris

    Chopper Commander

  • 129 posts

Posted Sun Aug 6, 2017 12:26 PM

For division operations involving anything other than powers of two, you will need to add a module to allow for this: "include div_mul.asm"

#46 8-bit_d-boy OFFLINE  

8-bit_d-boy

    Space Invader

  • Topic Starter
  • 46 posts

Posted Sun Aug 6, 2017 1:56 PM

I forgot to mention, I was trying to get the remainder with the // operator.

 

EDIT:

Attached current code.

 

Attached Files


Edited by 8-bit_d-boy, Mon Aug 7, 2017 6:29 PM.


#47 8-bit_d-boy OFFLINE  

8-bit_d-boy

    Space Invader

  • Topic Starter
  • 46 posts

Posted Mon Aug 14, 2017 2:27 PM

Is it possible to do a modulus operation without the advanced math modules? I can't get them working in my code. Haven't touched it in a while.

 

I'm trying to make it so that when the ball collides with the paddle, it stays outside of it to make determining the direction it reflects in easier.


Edited by 8-bit_d-boy, Mon Aug 14, 2017 2:28 PM.


#48 kdgarris OFFLINE  

kdgarris

    Chopper Commander

  • 129 posts

Posted Mon Aug 14, 2017 2:34 PM

I didn't have much luck getting the modulus with the // operator, either, but I changed how I did it, and didn't look into it deeply at the time.  Maybe it would be good to test it with a small test program that's easier to debug.



#49 5-11under ONLINE  

5-11under

    River Patroller

  • 3,201 posts
  • Location:Ontario, Canada

Posted Mon Aug 14, 2017 2:38 PM

Posting here to keep an eye on the thread. Looks interesting and you had me at "hockey" :D

 

It looks like a classic Leafs versus Habs game. ;)



#50 kdgarris OFFLINE  

kdgarris

    Chopper Commander

  • 129 posts

Posted Mon Aug 14, 2017 2:39 PM

For reflection code, I wonder if it would be helpful to keep track of the previous positions of both the ball and the paddle?  That way if the ball hits the paddle and the paddle hasn't moved, then you could have the ball reflect on the opposite direction that it came from.  Otherwise, if the paddle hits the ball, then have the ball jump back in the direction that the paddle is going.  It's not perfect physics, but it may be a decent starting point?

 

Maybe others will have better ideas on how to compute this in a more realistic way.







Also tagged with one or more of these keywords: new game, air hockey, development

0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users