Jump to content

Lodmot

Members
  • Content Count

    979
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Lodmot


  1. Well, what I'm trying to do exactly is make a car game that has physics (obviously).

    In the physics engine here, I have two directional variables, one is the direction the car is facing, and another is resistance direction, which allows the car to swerve around a corner if it turns while it's at full throttle.

    Then I have the velocity variable which is always adding up by 1's till it gets to 100 at which it loops back to 0.

    When you press right, left, up or down on the joystick, an acceleration variable adds up by 4, and maxes out at 100.

    At the same time, it will also set the velocity value to the value of the acceleration variable. This is to make it so the

    higher the velocity value is, the sooner it gets to 100.

    The velocity variable then reads the acceleration variable and detects whether it's higher than 100, and if so, it moves the car one pixel in the corresponding direction.

    If you let go of the joystick, I have that variable decrease by 1 until it gets back to 0, allowing for the car to keep momentum for a period of time.

     

     

    I'm not sure if that's EXACTLY how it works... It's extremely confusing even for me, even though I wrote it...

    It took me a while to get it to do exactly what I wanted it to do. xD


  2. Alright, so I gave a crack at optimizing my code.

    This is really just way too confusing for me to even figure out.

     

    Right now the code looks like this:

     

    __Physics_P1
       rem PLAYER 1 CAR PHYSICS
       rem Calculate Car Acceleration and move car accordingly
       if P1_Health=0 then P1_Acceleration=0
       if P1_Acceleration<=75 then P1_Velocity=P1_Velocity+P1_Acceleration
       if P1_Acceleration>75 then P1_Velocity=P1_Velocity+P1_Acceleration/2
       if !switchleftb && P1_Acceleration=100 then P1_Velocity=101
       if P1_Velocity>100 && P1_Acceleration>75 then P1_Velocity=100 : P1_Speed1=1 : P1_Speed2=1
       if P1_Velocity>100 && P1_Acceleration<=75 then P1_Velocity=100 : P1_Speed1=0 : P1_Speed2=1
       if joy0right then P1_Acceleration=P1_Acceleration+4
       if joy0up then P1_Acceleration=P1_Acceleration+4
       if joy0down then P1_Acceleration=P1_Acceleration+4
       if joy0left then P1_Acceleration=P1_Acceleration+4
       if P1_Acceleration>0 then P1_Acceleration=P1_Acceleration-1
       if P1_Acceleration<1 then P1_Acceleration=0
       if P1_Acceleration>100 then P1_Acceleration=100 : P1_Resistance=0
       if P1_Acceleration=100 then P1_Speed1=1 : P1_Speed2=1
       if P1_Acceleration=0 then P1_Velocity=0
       if P1_Velocity<100 then P1_Speed1=0 : P1_Speed2=0
       if P1_Velocity=100 then P1_Velocity=0
       if !joy0up && !joy0down && !joy0left && !joy0right then P1_Resistance=0
       if !P1_Direction1 && P1_Speed2 then goto 694 else goto 698
    694    if P1_Direction2 && P1_Speed1 then player0x=player0x+2
       if P1_Direction2 && !P1_Speed1 then player0x=player0x+1
       if !P1_Direction2 && P1_Speed1 then player0y=player0y-2
       if !P1_Direction2 && !P1_Speed1 then player0y=player0y-1
    698    if P1_Direction1 && P1_Speed2 then 699 else 707
    699    if !P1_Direction2 && P1_Speed1 then player0x=player0x-2
       if !P1_Direction2 && !P1_Speed1 then player0x=player0x-1
       if P1_Direction2 && P1_Speed1 then player0y=player0y+2
       if P1_Direction2 && !P1_Speed1 then player0y=player0y+1
    
       rem Decrease carspeed when the opposite directional key is pressed while the car is moving
    707    if P1_Acceleration<=1 then 714
       if !P1_Direction1 && P1_Direction2 && joy0left then P1_Acceleration=P1_Acceleration-6
       if !P1_Direction1 && !P1_Direction2 && joy0up then P1_Acceleration=P1_Acceleration-6
       if P1_Direction1 && !P1_Direction2 && joy0right then P1_Acceleration=P1_Acceleration-6
       if P1_Direction1 && P1_Direction2 && joy0down then P1_Acceleration=P1_Acceleration-6
       rem Check whether car's acceleration is being resisted or not
    714 if P1_Acceleration>60 then 720
       if P1_Acceleration<=60 && joy0right then P1_Direction1=0 : P1_Direction2=1
       if P1_Acceleration<=60 && joy0down then P1_Direction1=0 : P1_Direction2=0
       if P1_Acceleration<=60 && joy0left then P1_Direction1=1 : P1_Direction2=0
       if P1_Acceleration<=60 && joy0up then P1_Direction1=1 : P1_Direction2=1
       goto 728
    720    if P1_Direction1 && P1_Direction2 && joy0right then P1_Acceleration=0 : P1_Direction1=0 : P1_Direction2=1 : P1_Resistance=4
       if !P1_Direction1 && !P1_Direction2 && joy0right then P1_Acceleration=0 : P1_Direction1=0 : P1_Direction2=1 : P1_Resistance=2
       if P1_Direction1 && P1_Direction2 && joy0left then P1_Acceleration=0 : P1_Direction1=1 : P1_Direction2=0 : P1_Resistance=4 
       if !P1_Direction1 && !P1_Direction2 && joy0left then P1_Acceleration=0 : P1_Direction1=1 : P1_Direction2=0 : P1_Resistance=2
       if P1_Direction1 && !P1_Direction2 && joy0up then P1_Acceleration=0 : P1_Direction1=1 : P1_Direction2=1 : P1_Resistance=3
       if !P1_Direction1 && P1_Direction2 && joy0up then P1_Acceleration=0 : P1_Direction1=1 : P1_Direction2=1 : P1_Resistance=1
       if P1_Direction1 && !P1_Direction2 && joy0down then P1_Acceleration=0 : P1_Direction1=0 : P1_Direction2=0 : P1_Resistance=3
       if !P1_Direction1 && P1_Direction2 && joy0down then P1_Acceleration=0 : P1_Direction1=0 : P1_Direction2=0 : P1_Resistance=1
    728    if P1_Resistance=1 then player0x=player0x+1
       if P1_Resistance=2 then player0y=player0y-1
       if P1_Resistance=3 then player0x=player0x-1
       if P1_Resistance=4 then player0y=player0y+1
       if player1y<98 then goto __Physics_A1 bank4
    __Physics_A1
       rem AI1 CAR PHYSICS
       rem Calculate Car AI1 Acceleration and move car accordingly
       if Car2_Health=0 then AI1_IsAccel=0
       if Car2_Acceleration<=75 then Car2_Velocity=Car2_Velocity+Car2_Acceleration else Car2_Velocity=Car2_Velocity+Car2_Acceleration/2
       if !switchleftb && Car2_Acceleration=100 then Car2_Velocity=101
       if Car2_Velocity>100 && Car2_Acceleration>75 then Car2_Velocity=100 : Car2_Speed1=1 : Car2_Speed2=1
       if Car2_Velocity>100 && Car2_Acceleration<=75 then Car2_Velocity=100 : Car2_Speed1=0 : Car2_Speed2=1
       if AI1_IsAccel then Car2_Acceleration=Car2_Acceleration+4
       if Car2_Acceleration>0 then Car2_Acceleration=Car2_Acceleration-1
       if Car2_Acceleration<1 then Car2_Acceleration=0
       if Car2_Acceleration>100 then Car2_Acceleration=100
       if Car2_Acceleration=100 then Car2_Speed1=1 : Car2_Speed2=1
       if Car2_Acceleration=0 then Car2_Velocity=0
       if Car2_Velocity<100 then Car2_Speed1=0 : Car2_Speed2=0
       if Car2_Velocity=100 then Car2_Velocity=0
       if Car2_Direction1 then 813
       if Car2_Direction2 && Car2_Speed1 && Car2_Speed2 then player1x=player1x+2
       if Car2_Direction2 && !Car2_Speed1 && Car2_Speed2 then player1x=player1x+1
       if !Car2_Direction2 && Car2_Speed1 && Car2_Speed2 then player1y=player1y-2
       if !Car2_Direction2 && !Car2_Speed1 && Car2_Speed2 then player1y=player1y-1
       goto 821
    813    if !Car2_Direction2 && Car2_Speed1 && Car2_Speed2 then player1x=player1x-2
       if !Car2_Direction2 && !Car2_Speed1 && Car2_Speed2 then player1x=player1x-1
       if Car2_Direction2 && Car2_Speed1 && Car2_Speed2 then player1y=player1y+2
       if Car2_Direction2 && !Car2_Speed1 && Car2_Speed2 then player1y=player1y+1
    
      rem Check whether car's acceleration is being resisted or not
    821    if AI1_IsAccel && Car2_Acceleration<70 then 822 else 831
    822    if !Car2_Direction1 && Car2_Direction2 && Car2_ResistanceDir1 && Car2_ResistanceDir2 then player1y=player1y+1
       if Car2_Direction1 && !Car2_Direction2 && Car2_ResistanceDir1 && Car2_ResistanceDir2 then player1y=player1y+1
       if !Car2_Direction1 && Car2_Direction2 && !Car2_ResistanceDir1 && !Car2_ResistanceDir2 then player1y=player1y-1
       if Car2_Direction1 && !Car2_Direction2 && !Car2_ResistanceDir1 && !Car2_ResistanceDir2 then player1y=player1y-1
       if Car2_Direction1 && Car2_Direction2 && !Car2_ResistanceDir1 && Car2_ResistanceDir2 then player1x=player1x+1
       if !Car2_Direction1 && !Car2_Direction2 && !Car2_ResistanceDir1 && Car2_ResistanceDir2 then player1x=player1x+1
       if !Car2_Direction1 && !Car2_Direction2 && Car2_ResistanceDir1 && !Car2_ResistanceDir2 then player1x=player1x-1
       if Car2_Direction1 && Car2_Direction2 && Car2_ResistanceDir1 && !Car2_ResistanceDir2 then player1x=player1x-1
       goto 836
    831    if Car2_Acceleration<=75 then Car2_ResistanceDir1=Car2_Direction1 : Car2_ResistanceDir2=Car2_Direction2 : goto 836 else 832
    832    if !Car2_Direction1 && Car2_ResistanceDir1 then Car2_Acceleration=0
       if Car2_Direction1 && !Car2_ResistanceDir1 then Car2_Acceleration=0
       if Car2_Direction2 && !Car2_ResistanceDir2 then Car2_Acceleration=0
       if !Car2_Direction2 && Car2_ResistanceDir2 then Car2_Acceleration=0
    836 if player2y<98 then goto __A2_Physics
       goto __GAME_Main_Loop bank2
    __A2_Physics
       rem AI2 CAR PHYSICS
       rem Calculate Car AI1 Acceleration and move car accordingly
       if AI2_Health=0 then AI2_IsAccel=0
       if AI2_Acceleration<=75 then AI2_Velocity=AI2_Velocity+AI2_Acceleration else AI2_Velocity=AI2_Velocity+AI2_Acceleration/2
       if !switchleftb && AI2_Acceleration=100 then AI2_Velocity=101
       if AI2_Velocity>100 && AI2_Acceleration>75 then AI2_Velocity=100 : AI2_Speed1=1 : AI2_Speed2=1
       if AI2_Velocity>100 && AI2_Acceleration<=75 then AI2_Velocity=100 : AI2_Speed1=0 : AI2_Speed2=1
       if AI2_IsAccel then AI2_Acceleration=AI2_Acceleration+4
       if AI2_Acceleration>0 then AI2_Acceleration=AI2_Acceleration-1
       if AI2_Acceleration<1 then AI2_Acceleration=0
       if AI2_Acceleration>100 then AI2_Acceleration=100
       if AI2_Acceleration=100 then AI2_Speed1=1 : AI2_Speed2=1
       if AI2_Acceleration=0 then AI2_Velocity=0
       if AI2_Velocity<100 then AI2_Speed1=0 : AI2_Speed2=0
       if AI2_Velocity=100 then AI2_Velocity=0
       if AI2_Direction1 then 862
       if AI2_Direction2 && AI2_Speed1 && AI2_Speed2 then player2x=player2x+2
       if AI2_Direction2 && !AI2_Speed1 && AI2_Speed2 then player2x=player2x+1
       if !AI2_Direction2 && AI2_Speed1 && AI2_Speed2 then player2y=player2y-2
       if !AI2_Direction2 && !AI2_Speed1 && AI2_Speed2 then player2y=player2y-1
       goto 868
    862    if !AI2_Direction2 && AI2_Speed1 && AI2_Speed2 then player2x=player2x-2
       if !AI2_Direction2 && !AI2_Speed1 && AI2_Speed2 then player2x=player2x-1
       if AI2_Direction2 && AI2_Speed1 && AI2_Speed2 then player2y=player2y+2
       if AI2_Direction2 && !AI2_Speed1 && AI2_Speed2 then player2y=player2y+1
       rem Check whether car's acceleration is being resisted or not
    868    if AI2_IsAccel && AI2_Acceleration<70 then 869 else 877
    869    if !AI2_Direction1 && AI2_Direction2 && AI2_ResistanceDir1 && AI2_ResistanceDir2 then player2y=player2y+1
       if AI2_Direction1 && !AI2_Direction2 && AI2_ResistanceDir1 && AI2_ResistanceDir2 then player2y=player2y+1
       if !AI2_Direction1 && AI2_Direction2 && !AI2_ResistanceDir1 && !AI2_ResistanceDir2 then player2y=player2y-1
       if AI2_Direction1 && !AI2_Direction2 && !AI2_ResistanceDir1 && !AI2_ResistanceDir2 then player2y=player2y-1
       if AI2_Direction1 && AI2_Direction2 && !AI2_ResistanceDir1 && AI2_ResistanceDir2 then player2x=player2x+1
       if !AI2_Direction1 && !AI2_Direction2 && !AI2_ResistanceDir1 && AI2_ResistanceDir2 then player2x=player2x+1
       if !AI2_Direction1 && !AI2_Direction2 && AI2_ResistanceDir1 && !AI2_ResistanceDir2 then player2x=player2x-1
       if AI2_Direction1 && AI2_Direction2 && AI2_ResistanceDir1 && !AI2_ResistanceDir2 then player2x=player2x-1
       goto 882
    877    if AI2_Acceleration<=75 then AI2_ResistanceDir1=AI2_Direction1 : AI2_ResistanceDir2=AI2_Direction2 : goto 882 else 878
    878    if !AI2_Direction1 && AI2_ResistanceDir1 then AI2_Acceleration=0
       if AI2_Direction1 && !AI2_ResistanceDir1 then AI2_Acceleration=0
       if AI2_Direction2 && !AI2_ResistanceDir2 then AI2_Acceleration=0
       if !AI2_Direction2 && AI2_ResistanceDir2 then AI2_Acceleration=0
    882    goto __GAME_Main_Loop bank2
    

     

    A bit better than it was before, and I did notice a small decrease in scanlines when I do an ALT-L in Stella.

    But it's still pretty bad, and ontop of that, the changes I made caused the actual control to feel different.

    I preferred how the car controlled before, and it seems to me nothing should be acting different.

     

    I'm probably doing something wrong, but there really is so much code I have to go through and it's just

    turning my brain into a watermelon.


  3. Okay. xDDD!!!!!

    Yeah, I'm almost 154% certain that that's why the game is slowing down! LOL!

    The only thing is, is there a limit to how many loops for skipping some code I could do?

    Or maybe I could use line numbers instead.


  4. Well, those sound like really good suggestions. I'll give it a shot tonight. It will take a long time though. xD

     

    The code I think is the main culprit is the physics engine, and the entire thing looks like this:

     

    __Physics_P1
       rem PLAYER 1 CAR PHYSICS
       rem Calculate Car Acceleration and move car accordingly
       if P1_Health=0 then P1_Acceleration=0
       if P1_Acceleration<=75 then P1_Velocity=P1_Velocity+P1_Acceleration
       if P1_Acceleration>75 then P1_Velocity=P1_Velocity+P1_Acceleration/2
       if !switchleftb && P1_Acceleration=100 then P1_Velocity=101
       if P1_Velocity>100 && P1_Acceleration>75 then P1_Velocity=100 : P1_Speed1=1 : P1_Speed2=1
       if P1_Velocity>100 && P1_Acceleration<=75 then P1_Velocity=100 : P1_Speed1=0 : P1_Speed2=1
       if joy0right then P1_Acceleration=P1_Acceleration+4
       if joy0up then P1_Acceleration=P1_Acceleration+4
       if joy0down then P1_Acceleration=P1_Acceleration+4
       if joy0left then P1_Acceleration=P1_Acceleration+4
       if P1_Acceleration>0 then P1_Acceleration=P1_Acceleration-1
       if P1_Acceleration<1 then P1_Acceleration=0
       if P1_Acceleration>100 then P1_Acceleration=100 : P1_Resistance=0
       if P1_Acceleration=100 then P1_Speed1=1 : P1_Speed2=1
       if P1_Acceleration=0 then P1_Velocity=0
       if P1_Velocity<100 then P1_Speed1=0 : P1_Speed2=0
       if P1_Velocity=100 then P1_Velocity=0
       if !joy0up && !joy0down && !joy0left && !joy0right then P1_Resistance=0
       if !P1_Direction1 && P1_Direction2 && P1_Speed1 && P1_Speed2 then player0x=player0x+2
       if !P1_Direction1 && P1_Direction2 && !P1_Speed1 && P1_Speed2 then player0x=player0x+1
       if !P1_Direction1 && !P1_Direction2 && P1_Speed1 && P1_Speed2 then player0y=player0y-2
       if !P1_Direction1 && !P1_Direction2 && !P1_Speed1 && P1_Speed2 then player0y=player0y-1
       if P1_Direction1 && !P1_Direction2 && P1_Speed1 && P1_Speed2 then player0x=player0x-2
       if P1_Direction1 && !P1_Direction2 && !P1_Speed1 && P1_Speed2 then player0x=player0x-1
       if P1_Direction1 && P1_Direction2 && P1_Speed1 && P1_Speed2 then player0y=player0y+2
       if P1_Direction1 && P1_Direction2 && !P1_Speed1 && P1_Speed2 then player0y=player0y+1
    
       rem Decrease carspeed when the opposite directional key is pressed while the car is moving
       if P1_Acceleration>1 && !P1_Direction1 && P1_Direction2 && joy0left then P1_Acceleration=P1_Acceleration-6
       if P1_Acceleration>1 && !P1_Direction1 && !P1_Direction2 && joy0up then P1_Acceleration=P1_Acceleration-6
       if P1_Acceleration>1 && P1_Direction1 && !P1_Direction2 && joy0right then P1_Acceleration=P1_Acceleration-6
       if P1_Acceleration>1 && P1_Direction1 && P1_Direction2 && joy0down then P1_Acceleration=P1_Acceleration-6
       rem Check whether car's acceleration is being resisted or not
       if P1_Acceleration<=60 && joy0right then P1_Direction1=0 : P1_Direction2=1
       if P1_Acceleration<=60 && joy0down then P1_Direction1=0 : P1_Direction2=0
       if P1_Acceleration<=60 && joy0left then P1_Direction1=1 : P1_Direction2=0
       if P1_Acceleration<=60 && joy0up then P1_Direction1=1 : P1_Direction2=1
       if P1_Acceleration>60 && P1_Direction1 && P1_Direction2 && joy0right then P1_Acceleration=0 : P1_Direction1=0 : P1_Direction2=1 : P1_Resistance=4
       if P1_Acceleration>60 && !P1_Direction1 && !P1_Direction2 && joy0right then P1_Acceleration=0 : P1_Direction1=0 : P1_Direction2=1 : P1_Resistance=2
       if P1_Acceleration>60 && P1_Direction1 && P1_Direction2 && joy0left then P1_Acceleration=0 : P1_Direction1=1 : P1_Direction2=0 : P1_Resistance=4 
       if P1_Acceleration>60 && !P1_Direction1 && !P1_Direction2 && joy0left then P1_Acceleration=0 : P1_Direction1=1 : P1_Direction2=0 : P1_Resistance=2
       if P1_Acceleration>60 && P1_Direction1 && !P1_Direction2 && joy0up then P1_Acceleration=0 : P1_Direction1=1 : P1_Direction2=1 : P1_Resistance=3
       if P1_Acceleration>60 && !P1_Direction1 && P1_Direction2 && joy0up then P1_Acceleration=0 : P1_Direction1=1 : P1_Direction2=1 : P1_Resistance=1
       if P1_Acceleration>60 && P1_Direction1 && !P1_Direction2 && joy0down then P1_Acceleration=0 : P1_Direction1=0 : P1_Direction2=0 : P1_Resistance=3
       if P1_Acceleration>60 && !P1_Direction1 && P1_Direction2 && joy0down then P1_Acceleration=0 : P1_Direction1=0 : P1_Direction2=0 : P1_Resistance=1
       if P1_Resistance=1 then player0x=player0x+1
       if P1_Resistance=2 then player0y=player0y-1
       if P1_Resistance=3 then player0x=player0x-1
       if P1_Resistance=4 then player0y=player0y+1
       if player1y<98 then goto __Physics_A1 bank4
       goto __GAME_Main_Loop bank2
    ----------------------------------------------------------
    bank 4
    __Physics_A1
       rem AI1 CAR PHYSICS
       rem Calculate Car AI1 Acceleration and move car accordingly
       if Car2_Health=0 then AI1_IsAccel=0
       if Car2_Acceleration<=75 then Car2_Velocity=Car2_Velocity+Car2_Acceleration
       if Car2_Acceleration>75 then Car2_Velocity=Car2_Velocity+Car2_Acceleration/2
       if !switchleftb && Car2_Acceleration=100 then Car2_Velocity=101
       if Car2_Velocity>100 && Car2_Acceleration>75 then Car2_Velocity=100 : Car2_Speed1=1 : Car2_Speed2=1
       if Car2_Velocity>100 && Car2_Acceleration<=75 then Car2_Velocity=100 : Car2_Speed1=0 : Car2_Speed2=1
       if AI1_IsAccel then Car2_Acceleration=Car2_Acceleration+4
       if Car2_Acceleration>0 then Car2_Acceleration=Car2_Acceleration-1
       if Car2_Acceleration<1 then Car2_Acceleration=0
       if Car2_Acceleration>100 then Car2_Acceleration=100
       if Car2_Acceleration=100 then Car2_Speed1=1 : Car2_Speed2=1
       if Car2_Acceleration=0 then Car2_Velocity=0
       if Car2_Velocity<100 then Car2_Speed1=0 : Car2_Speed2=0
       if Car2_Velocity=100 then Car2_Velocity=0
       if !Car2_Direction1 && Car2_Direction2 && Car2_Speed1 && Car2_Speed2 then player1x=player1x+2
       if !Car2_Direction1 && Car2_Direction2 && !Car2_Speed1 && Car2_Speed2 then player1x=player1x+1
       if !Car2_Direction1 && !Car2_Direction2 && Car2_Speed1 && Car2_Speed2 then player1y=player1y-2
       if !Car2_Direction1 && !Car2_Direction2 && !Car2_Speed1 && Car2_Speed2 then player1y=player1y-1
       if Car2_Direction1 && !Car2_Direction2 && Car2_Speed1 && Car2_Speed2 then player1x=player1x-2
       if Car2_Direction1 && !Car2_Direction2 && !Car2_Speed1 && Car2_Speed2 then player1x=player1x-1
       if Car2_Direction1 && Car2_Direction2 && Car2_Speed1 && Car2_Speed2 then player1y=player1y+2
       if Car2_Direction1 && Car2_Direction2 && !Car2_Speed1 && Car2_Speed2 then player1y=player1y+1
       rem Check whether car's acceleration is being resisted or not
       if AI1_IsAccel && Car2_Acceleration<70 && !Car2_Direction1 && Car2_Direction2 && Car2_ResistanceDir1 && Car2_ResistanceDir2 then player1y=player1y+1
       if AI1_IsAccel && Car2_Acceleration<70 && Car2_Direction1 && !Car2_Direction2 && Car2_ResistanceDir1 && Car2_ResistanceDir2 then player1y=player1y+1
       if AI1_IsAccel && Car2_Acceleration<70 && !Car2_Direction1 && Car2_Direction2 && !Car2_ResistanceDir1 && !Car2_ResistanceDir2 then player1y=player1y-1
       if AI1_IsAccel && Car2_Acceleration<70 && Car2_Direction1 && !Car2_Direction2 && !Car2_ResistanceDir1 && !Car2_ResistanceDir2 then player1y=player1y-1
       if AI1_IsAccel && Car2_Acceleration<70 && Car2_Direction1 && Car2_Direction2 && !Car2_ResistanceDir1 && Car2_ResistanceDir2 then player1x=player1x+1
       if AI1_IsAccel && Car2_Acceleration<70 && !Car2_Direction1 && !Car2_Direction2 && !Car2_ResistanceDir1 && Car2_ResistanceDir2 then player1x=player1x+1
       if AI1_IsAccel && Car2_Acceleration<70 && !Car2_Direction1 && !Car2_Direction2 && Car2_ResistanceDir1 && !Car2_ResistanceDir2 then player1x=player1x-1
       if AI1_IsAccel && Car2_Acceleration<70 && Car2_Direction1 && Car2_Direction2 && Car2_ResistanceDir1 && !Car2_ResistanceDir2 then player1x=player1x-1
       if Car2_Acceleration>70 && Car2_Acceleration<=75 then Car2_ResistanceDir1=Car2_Direction1 : Car2_ResistanceDir2=Car2_Direction2
       if Car2_Acceleration>75 && !Car2_Direction1 && Car2_ResistanceDir1 then Car2_Acceleration=0
       if Car2_Acceleration>75 && Car2_Direction1 && !Car2_ResistanceDir1 then Car2_Acceleration=0
       if Car2_Acceleration>75 && Car2_Direction2 && !Car2_ResistanceDir2 then Car2_Acceleration=0
       if Car2_Acceleration>75 && !Car2_Direction2 && Car2_ResistanceDir2 then Car2_Acceleration=0
       if player2y<98 then goto __A2_Physics
       goto __GAME_Main_Loop bank2
    __A2_Physics
       rem AI2 CAR PHYSICS
       rem Calculate Car AI1 Acceleration and move car accordingly
       if AI2_Health=0 then AI2_IsAccel=0
       if AI2_Acceleration<=75 then AI2_Velocity=AI2_Velocity+AI2_Acceleration
       if AI2_Acceleration>75 then AI2_Velocity=AI2_Velocity+AI2_Acceleration/2
       if !switchleftb && AI2_Acceleration=100 then AI2_Velocity=101
       if AI2_Velocity>100 && AI2_Acceleration>75 then AI2_Velocity=100 : AI2_Speed1=1 : AI2_Speed2=1
       if AI2_Velocity>100 && AI2_Acceleration<=75 then AI2_Velocity=100 : AI2_Speed1=0 : AI2_Speed2=1
       if AI2_IsAccel then AI2_Acceleration=AI2_Acceleration+4
       if AI2_Acceleration>0 then AI2_Acceleration=AI2_Acceleration-1
       if AI2_Acceleration<1 then AI2_Acceleration=0
       if AI2_Acceleration>100 then AI2_Acceleration=100
       if AI2_Acceleration=100 then AI2_Speed1=1 : AI2_Speed2=1
       if AI2_Acceleration=0 then AI2_Velocity=0
       if AI2_Velocity<100 then AI2_Speed1=0 : AI2_Speed2=0
       if AI2_Velocity=100 then AI2_Velocity=0
       if !AI2_Direction1 && AI2_Direction2 && AI2_Speed1 && AI2_Speed2 then player2x=player2x+2
       if !AI2_Direction1 && AI2_Direction2 && !AI2_Speed1 && AI2_Speed2 then player2x=player2x+1
       if !AI2_Direction1 && !AI2_Direction2 && AI2_Speed1 && AI2_Speed2 then player2y=player2y-2
       if !AI2_Direction1 && !AI2_Direction2 && !AI2_Speed1 && AI2_Speed2 then player2y=player2y-1
       if AI2_Direction1 && !AI2_Direction2 && AI2_Speed1 && AI2_Speed2 then player2x=player2x-2
       if AI2_Direction1 && !AI2_Direction2 && !AI2_Speed1 && AI2_Speed2 then player2x=player2x-1
       if AI2_Direction1 && AI2_Direction2 && AI2_Speed1 && AI2_Speed2 then player2y=player2y+2
       if AI2_Direction1 && AI2_Direction2 && !AI2_Speed1 && AI2_Speed2 then player2y=player2y+1
       rem Check whether car's acceleration is being resisted or not
       if AI2_IsAccel && AI2_Acceleration<70 && !AI2_Direction1 && AI2_Direction2 && AI2_ResistanceDir1 && AI2_ResistanceDir2 then player2y=player2y+1
       if AI2_IsAccel && AI2_Acceleration<70 && AI2_Direction1 && !AI2_Direction2 && AI2_ResistanceDir1 && AI2_ResistanceDir2 then player2y=player2y+1
       if AI2_IsAccel && AI2_Acceleration<70 && !AI2_Direction1 && AI2_Direction2 && !AI2_ResistanceDir1 && !AI2_ResistanceDir2 then player2y=player2y-1
       if AI2_IsAccel && AI2_Acceleration<70 && AI2_Direction1 && !AI2_Direction2 && !AI2_ResistanceDir1 && !AI2_ResistanceDir2 then player2y=player2y-1
       if AI2_IsAccel && AI2_Acceleration<70 && AI2_Direction1 && AI2_Direction2 && !AI2_ResistanceDir1 && AI2_ResistanceDir2 then player2x=player2x+1
       if AI2_IsAccel && AI2_Acceleration<70 && !AI2_Direction1 && !AI2_Direction2 && !AI2_ResistanceDir1 && AI2_ResistanceDir2 then player2x=player2x+1
       if AI2_IsAccel && AI2_Acceleration<70 && !AI2_Direction1 && !AI2_Direction2 && AI2_ResistanceDir1 && !AI2_ResistanceDir2 then player2x=player2x-1
       if AI2_IsAccel && AI2_Acceleration<70 && AI2_Direction1 && AI2_Direction2 && AI2_ResistanceDir1 && !AI2_ResistanceDir2 then player2x=player2x-1
       if AI2_Acceleration>70 && AI2_Acceleration<=75 then AI2_ResistanceDir1=AI2_Direction1 : AI2_ResistanceDir2=AI2_Direction2
       if AI2_Acceleration>75 && !AI2_Direction1 && AI2_ResistanceDir1 then AI2_Acceleration=0
       if AI2_Acceleration>75 && AI2_Direction1 && !AI2_ResistanceDir1 then AI2_Acceleration=0
       if AI2_Acceleration>75 && AI2_Direction2 && !AI2_ResistanceDir2 then AI2_Acceleration=0
       if AI2_Acceleration>75 && !AI2_Direction2 && AI2_ResistanceDir2 then AI2_Acceleration=0
       goto __GAME_Main_Loop bank2
    


  5. Alright, so I'm still kind of a beginner programmer using Batari Basic, but I've also been working on a pretty ambitious project called Auto Mayhem.

    Everything in the game works the way I want it to, but now I'm at the point where I wish I knew how to optimize my code, because it's running over the 262 scanline limit. So there are a few questions I have in regards to this:

    • Are there any detailed tutorials on code optimization for people who know the language, but are still relatively new to it?
    • When the code is processed by the Atari 2600 or an emulator, and an if-then statement proves to be false, does that if-then statement still use up cycles? (I'm guessing it does, seeing that it still has to determine whether the statement is true or false regardless)
    • I have a crap-ton of if-then statements in my game that are half-duplicate, e.g.:
       
      if P1_Acceleration&--#62;60 && P1_Direction1 && P1_Direction2 && joy0right then P1_Acceleration=0 : P1_Direction1=0 : P1_Direction2=1 : P1_Resistance=4
      if P1_Acceleration&--#62;60 && P1_Direction1 && P1_Direction2 && joy0left then P1_Acceleration=0 : P1_Direction1=1 : P1_Direction2=0 : P1_Resistance=4
      


      Even though the if statements are checking for very similar conditions, they're also checking another slightly different condition as well. It almost seems like I should be able to simplify these two statements into one. Is there any way to do this to save on cycles?

    • When action is at its max in my game, it runs up to about 280 scanlines. That's 18 scanlines over where I should be. Codewise, how "too much" exactly is that? In other words, do I have to remove/optimize the code by just a little to get down to 262, or do I have to remove/optimize almost the entire game?

    Any help is greatly appreciated. Thank you. ^^


  6. Dude, the RF cables are actually regular single RCA cables. Go to Radio Shack and find one for like 6 bucks.

     

    Thanks for the tip. Radio Shack seems to be carrying less and less necessities but I'll check.

    Not a problem. ^^

    Also, I'm not sure if you're new at fixing Atari consoles or not, but in case you're not:

    On the older 2600 models, the RF cable looks like it's hardwired to the console, but when you take the system apart, you'll notice that the RF cable actually plugs in on the inside as well, which means you don't have to cut the wire and solder anything, which is awesome.


  7. Just literally got this in the mail today!

    Bought it on eBay for 34 dollars, and fixed it to nearly perfect working condition. Hell yeah. ;D

    The guy said it was missing an RF cable, so I replaced it. I also had to replace the PIA and MPU chips. Other than that, the system is working great now.

    Awesome reception, and I can't believe how fat this thing is compared to a regular sixer! DAYUMN!!!!!!!!

    I replaced two of the three chips in the main board, but before I did, I got the latest date code from them, which was 7734.

     

    The only problem it still has is that the fire buttons will be triggered by themselves after a period of use.

     

    photobucket-2994-1331095171956.jpg?t=1331095172

    photobucket-5156-1331095039812.jpg?t=1331095040

     

    SERIAL NO: 67410F

    TV Type: NTSC (However I discovered that adjusting the vertical hold on an older TV allows PAL games to display correctly as well)

    Date Codes: 7734, 7709, 7732 (These are the original ones that came with the system)

    Channel A/B Select: No switch, and no hole, tramsmits to channel 3

    Working: Wasn't before, but now it is.


  8. Take a look at this:

     

    vcs_09.jpg

     

    Why.... it appears to be a heavy 4-switcher!

    Here's another picture, to kinda prove that I'm not making this up:

    Atari_2600_VCS.jpg

     

    Has anyone else noticed this? Are there any heavy four-switcher Atari's?

    Or... did they just simply use the heavy sixer picture and paint out the two other switches?


  9. Alright... I think I effed up xDDD

    I tried implementing AI into my game today, and the whole thing runs extremely slow now. I should probably refrain from bit operations for a while. 8D

     

    I was hoping to get 3 cars all with working physics and AI on the screen at once, shooting each other and what not, but it's starting to look like an impossible feat. I wish there was a way I can figure out how many CPU cycles my game is using up..

     

    Guess the Atari 2600 wasn't exactly prepared for a game like Twisted Metal. xD


  10. Alright, I've finally finished re-writing the game with the new variable and bit aliases that I laid out for the game.

    And low and behold................. it works perfectly! No slowdowns whatsoever. :3

     

    Now I feel a lot better about being able to make this game.

     

    I plan on just doing it a little at a time, and I'm gonna be doing a lot of testing on my real Atari in between.

    Best thing to do is get the basics done first, and then once everything is working solidly then I could start adding in nice little extras like explosions or sounds.


  11. Okay, that's good. I think ill be okay. I pretty much have all the game mechanics in there that its going to have. The game is going to be a 16k rom, and I still have yet to use up the first bank, so rom space isn't a problem. I can also set speed optimization and write a bit more code to detect whether a bit needs to be changed or not, so the game isn't unnecessarily setting the bit value when it doesn't need to. Hopefully that would save the CPU a bit.

     

    I don't understand why setting individual bits would take more cpu than setting regular variables though. Id figure it would take less cpu for setting single bits, since the game would only be setting one bit rather than 8 bits at one time, you know?


  12. I'm not exactly sure what you mean by converting the bytes...

    I should have been more precise... "converting your variables to use bits instead of bytes".

     

     

    What is involved in using Superchip RAM? I've seen that mentioned in the guide, but I don't quite understand it.

    Not a whole lot. The main wrinkle is you that you read from one location of superchip memory, and write to another. So to add 10 to a superchip variable you'd do something like...

     

     set romsize 8kSC
    
     dim spaceshipx_r=r100
     dim spaceshipx_w=w100
    
     spaceshipx_w=spaceshipx_r+10
    

     

    I think I may have been converting the variables from bytes to bits all along.

    Now my code is looking more like this:

     

    rem Setup Variable and Bit Aliases
    dim P1_Acceleration=a
    def P1_Speed1=b{0}
    def P1_Speed2=b{1}
    def P1_Direction1=b{2}
    def P1_Direction2=b{3}
    def P1_ResistanceDir1=b{4}
    def P1_ResistanceDir2=b{5}
    def P1_MissileDir1=b{6}
    def P1_MissileDir2=b{7}
    dim P1_Velocity=c
    dim P1_Weapon=d
    

    Not sure if that's what you meant. I'm just trying to avoid confusion by giving each individual bit a name. Those were all separate variables at one point, so that's when I thought maybe just using individual bits for each asset would help.

    Also, giving aliases uses more ROM? I was kinda hoping that the compiler would convert all the aliases back to their letter variables..


  13. If I'm correct, this variable setup should free up 7 VARIABLES!!! WOOHOO!!!!! The reason why I'm posting this here is, I just wanted to make sure bits could be used in this fashion. Logically, I think I should have no problems. The only matter I see there being is that it may get very confusing figuring out which bits to apply where, when I'm editing the game.

     

    It will work, and yes it can get confusing.

     

    It's worth mentioning that bitwise ops usually take up more ROM and CPU than bytewise ones, so it's a trade-off. To minimise that trade-off, you can convert those bytes that are accessed the least in your code.

     

    If you're using the standard kernel, you also might look at using var44-var47 which are normally hidden unless you're scrolling. And there's also the possibility of switching the game to superchip ram.

    Well, I'm using the multisprite kernel to display 3 cars on the screen at once, so that's why I resorted to this method.

    I'm not exactly sure what you mean by converting the bytes...

    What is involved in using Superchip RAM? I've seen that mentioned in the guide, but I don't quite understand it.

     

    As you could tell, I've been learning a lot today about BB, but I'm also still pretty new at it. xD


  14. After reading the guide on RT's website, I've figured out how to modify single bits to save a shitload of variables in my game. Before, I thought I'd be lucky to get 3 cars in the screen at once, but now, I think there's enough resources for even 5 cars!

     

    I've laid out how I plan on using bits to control multiple actions in a mere two to three variables.

    ______________________________________________

     

    a = P1 Car Acceleration

    b = P1 Car Speed

    P1 Car Direction

    P1 Car Resistance Direction

    P1 Missile Direction

    c = P1 Car Velocity

    d = P1 Selected Weapon

     

    AI Global:

     

    e = AI1/P2 Car is Accelerating (1 bit)

    AI1/P2 Direction (2 bits)

    AI2 Firing Action (1 bit)

    AI2 Car is Accelerating (1 bit)

    AI2 Car Direction (2 bits)

    AI2 Firing Action (1 bit)

    f = AI Timer

     

    AI Car 1:

     

    g = Car Acceleration

    h = Car Velocity

    i = Speed (2 bits)

    Resistance Direction(2 bits)

    Missile Direction (2 bits)

    Selected Weapon (2 bits)

     

     

     

    AI Car 2:

    j = AI2 Car Acceleration

    k = Car Velocity

    l = Speed (2 bits)

    Resistance Direction (2 bits)

    Missile Direction (2 bits)

    Selected Weapon (2 bits)

     

     

     

    m = P1 Health

    n = AI1/P2 Health

    o = AI2 Health

    p = AUDV0

    q = AUDF0

    r = AUDV1

    s = AUDF1

     

    temp3 = Car AI 1 Control

    temp4 = Car AI 2 Control

    ______________________________________________

     

    Player 1 Multi-Function Variable – b

     

    00xxxxxx = Car Speed is 0

    01xxxxxx = Car Speed is 1

    11xxxxxx = Car Speed is 2

     

    xx01xxxx = Car Direction is Right

    xx00xxxx = Car Direction is Down

    xx10xxxx = Car Direction is Left

    xx11xxxx = Car Direction is Up

     

    xxxx01xx = Resistance Direction is Right

    xxxx00xx = Resistance Direction is Down

    xxxx10xx = Resistance Direction is Left

    xxxx11xx = Resistance Direction is Up

     

    xxxxxx01 = Missile Direction is Right

    xxxxxx00 = Missile Direction is Down

    xxxxxx10 = Missile Direction is Left

    xxxxxx11 = Missile Direction is Up

     

     

    AI Global Variable – e

     

    AI Car 1: Bits 0,1,2,3

    AI Car 2: Bits 4,5,6,7

     

    xx0x = not accelerating

    xx1x = accelerating

    00xx = facing down

    11xx = facing up

    01xx = facing right

    10xx = facing left

    xxx0 = not firing

    xxx1 = firing

     

    AI Action Variable 2 – i for AI1 and l for AI2

     

    xxxxxx00 = Speed 0

    xxxxxx01 = Speed 1

    xxxxxx10 = Speed 2

     

    xxxx01xx = Resistance Direction is right

    xxxx00xx = Resistance Direction is down

    xxxx11xx = Resistance Direction is up

    xxxx10xx = Resistance Direction is left

     

    xx01xxxx = Missile Direction is Right

    xx00xxxx = Missile Direction is Down

    xx10xxxx = Missile Direction is Left

    xx11xxxx = Missile Direction is Up

     

    00xxxxxx = Weapon Selected is Missile

    01xxxxxx = Weapon Selected is Remote Mine

    11xxxxxx = Weapon Selected is Homing Missile

    10xxxxxx = Weapon Selected is Lightning Bolt

    ________________________________________________

     

    If I'm correct, this variable setup should free up 7 VARIABLES!!! WOOHOO!!!!! The reason why I'm posting this here is, I just wanted to make sure bits could be used in this fashion. Logically, I think I should have no problems. The only matter I see there being is that it may get very confusing figuring out which bits to apply where, when I'm editing the game.


  15. Hey. ^^ Just wanted to say VisualBB has been working great for me so far. I can't stop using it. :3

     

    The only weird issue I've ran into is, the "macro" command isn't recognized in VisualBB, even though it's listed in the documentation.

    Therefore I haven't been able to utilize nybble variables in my game that I'm working on now.

     

    I'm using version 554. Perhaps there's a newer version I don't have? Or maybe an asm file I need to include in my code?

     

    Thanks. ^^


  16. I found a strange glitch with the multisprite kernel.

     

    In my game, I have it so when the car changes direction, it switches to the corresponding sprite for that direction.

    However on one of the directions, the car sprite has an extra line at the top that shouldn't be there. I checked the sprite code

    and the line isn't there. Interestingly enough, if I change around the order of the loops in the code, the line will go to a different

    directional sprite. It seems to be a timing issue of some kind.... Perhaps I've made the code between each drawscreen too long?

    I should mention I wrote a physics engine for the car, so that along with the drawing of missiles that the car fires, along with the

    directional sprites, maybe is pushing it a bit?

     

    EDIT: As I was trying to figure out the problem, I eventually said "screw it", and continued work on the game.

    Then after adding a few pieces of unrelated code into the game and testing it again, the weird sprite glitch mysteriously disappeared.

    Strange.......

     

    So I guess..... uh..... this issue has been resolved...? xD

    default.bas

    default.bas.bin


  17. Alright. Well, I'm still waiting for the two custom cartridges..

    When I look in my account's order history, it doesn't list my cartridges as shipped, it still says the order is Pending...

     

    I understand they do a professional job and they make their cartridges with care; that's fine..

    But it's also kind of odd that it would take this long. I sent my binary file and labels the night I placed the order, and

    it was stated on one of the pages that the cartridges would actually ship within two business days of receiving those pieces.

     

    Honestly, with all due respect to AA, I'm a little annoyed...

×
×
  • Create New...