# New Game: Air Hockey

new game air hockey development

58 replies to this topic

### #51 8-bit_d-boyOFFLINE

8-bit_d-boy

Star Raider

• Topic Starter
• 55 posts

Posted Tue Aug 15, 2017 2:36 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.

Thanks, that's a good idea.

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.

If it's not too much to ask, could you find it?

### #52 kdgarrisOFFLINE

kdgarris

Moonsweeper

• 326 posts

Posted Wed Aug 16, 2017 4:31 AM

I don't even remember what section code I was working on where I was trying to get the modulus. It was rewritten in a way that the modulus was no longer needed.

If you want to get the modulus manually, you could do something like this:

```   temp1 = dividend / divisor
modulus = dividend - (temp1 * divisor)```

If you want to report a bug with the // operator, I suggest starting a new thread, and creating a small test program that demonstrates the problem.

### #53 ZackAttackOFFLINE

ZackAttack

Dragonstomper

• 710 posts
• Location:Orlando, FL US

Posted Wed Aug 16, 2017 8:03 AM

Is it possible to do a modulus operation without the advanced math modules?

If you can limit it to a power of 2 I think you can just do a bitwise AND of 2n-1.

5 mod 2 = 5 & 1 = 1

### #54 8-bit_d-boyOFFLINE

8-bit_d-boy

Star Raider

• Topic Starter
• 55 posts

Posted Wed Aug 16, 2017 1:22 PM

I don't even remember what section code I was working on where I was trying to get the modulus. It was rewritten in a way that the modulus was no longer needed.

If you want to get the modulus manually, you could do something like this:

```   temp1 = dividend / divisor
modulus = dividend - (temp1 * divisor)```

If you want to report a bug with the // operator, I suggest starting a new thread, and creating a small test program that demonstrates the problem.

Thanks! I'll have to try this.

### #55 8-bit_d-boyOFFLINE

8-bit_d-boy

Star Raider

• Topic Starter
• 55 posts

Posted Thu Aug 17, 2017 7:59 PM

Hmmm, now I'm getting this error:

```--- Unresolved Symbol List

284 bytes of ROM space left

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

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

What does it mean by "branch out of range"?

That reminds me, I hope RT is doing okay.

Here's the code:

#### Attached Files

Edited by 8-bit_d-boy, Thu Aug 17, 2017 7:59 PM.

### #56 Random TerrainOFFLINE

Random Terrain

Visual batari Basic User

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

Posted Thu Aug 17, 2017 8:45 PM

If you change this:

```   if scoring <> 61 then _skip_ball_movment
```

to this:

`   if scoring <> 61 then goto _skip_ball_movment`

It will compile.

### #57 8-bit_d-boyOFFLINE

8-bit_d-boy

Star Raider

• Topic Starter
• 55 posts

Posted Thu Aug 17, 2017 8:56 PM

YOU'RE ALIVE!!

If you change this:

```   if scoring <> 61 then _skip_ball_movment
```

to this:

`   if scoring <> 61 then goto _skip_ball_movment`

It will compile.

Oh crap, its  so simple, how did I miss it?

Also I think I forgot to mention, I added use of the difficulty switches: players will no longer be able to move fast with the fire button with the switch set to "Advanced".

EDIT:

So I compiled it and it works!
That said, I have good news, and bad news.

Bad news is I kinda forgot how some of my code worked(or at least was supposed to) and some bugs got introduced where the ball gets stuck in the bottom edge of the playfield and the ball doesn't move horizontally when you hit it from the side so I can't tell if that fixed the clipping issue.

Good news is there's like 1 frame where the screen flickers when you hit the ball at full force which looks REALLY cool, I'll include the ROM so you can see for yourself!

#### Attached Files

Edited by 8-bit_d-boy, Thu Aug 17, 2017 9:12 PM.

### #58 8-bit_d-boyOFFLINE

8-bit_d-boy

Star Raider

• Topic Starter
• 55 posts

Posted Sun Aug 20, 2017 5:00 PM

So by playing around with the code for about a minute, I've regained some understanding of how the code works and the bug where the ball does not move in a straight horizontal line when hit from the side is caused by the clip check code I just fixed(duh):

```	temp6 = bvx + bvy
if bvx > bvy then temp5 = bvx / bvy : temp4 = bvy else temp5 = bvy / bvx : temp4 = bvx

for temp3 = 0 to temp4
temp2 = temp3 / temp4
temp1 = temp3 - (temp2 * temp4)
if temp1 = 0 then if bvx > bvy then bally = bally + 1 : if bvy > bvx then ballx = ballx + 1
if temp1 <> 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
```

I'm gonna stare at it for a bit to try to figure out why it's not working properly.

### #59 8-bit_d-boyOFFLINE

8-bit_d-boy

Star Raider

• Topic Starter
• 55 posts

Posted Sat Sep 16, 2017 5:38 PM

Hey, guys, been a while. The GPU in my main computer died a couple weeks ago, so I've been using my laptop and just haven't signed in. I'll have to set up Batari Basic to get back to workin' on this.

### 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