- Space Invaders Help
- 10 Oct 2024 07:56:21 pm
- Last edited by Pixilized on 11 Oct 2024 10:55:22 am; edited 1 time in total
So, I’m making Space Invaders for my TI-84+, OS 2.55, compiling to doors, and I’ve found a bug I can’t figure out how to fix…
Whenever I exit the program (clear or quit), the calculator crashes and performs a RAM clear. If I don’t use the interrupt, it works just fine, but I know the interrupt isn’t the problem. It’s the function the interrupt is running, Tick(), but I can’t figure out what’s wrong with it…
I believe it’s something about the part where I update the invaders positions, as it worked fine before I added that. But I can’t find a single thing wrong with it.
Could I please have some help?
Here’s my source code (god I wish we could attach files)
Whenever I exit the program (clear or quit), the calculator crashes and performs a RAM clear. If I don’t use the interrupt, it works just fine, but I know the interrupt isn’t the problem. It’s the function the interrupt is running, Tick(), but I can’t figure out what’s wrong with it…
I believe it’s something about the part where I update the invaders positions, as it worked fine before I added that. But I can’t find a single thing wrong with it.
Could I please have some help?
Here’s my source code (god I wish we could attach files)
SourceCoder 3 (thetaSPCINVD) wrote:
:.SPACINVD Space Invaders
:
:#Icon(00005E806D8033007F8052B000300830043008000400003000FC01FE01FE01FE)
:DiagnosticOff
:
:.Ship
:[000000187EFFFFFF]->Pic0Ship
:
:.Shields
:[0000007FFFFCF0E0]->Pic0Shld
:[000000FEFF3F0F07]
:[0000007F00FCF0E0]
:[000000FE003F0F07]
:[0000007F00FC00E0]
:[000000FE003F0007]
:
:.Aliens
:[000000BDDB66FFA5]->Pic0Alen
:[0000003C7EDBE7BD]
:
:.Lasers
:[0000000018181818]->Pic0Lasr
:[0000000008100810]
:[0000000010081008]
:
:.Shields map
:Data(1,1,1)->GDB0
:1->{GDB0}->{1+GDB0}->{2+GDB0}
:
:.Alien position
:Data(8,20,32,44,56,68,80)->GDB0X
:Data(2,10,18,26)->GDB0Y
:
:.Variable RAM
:|E9872->->^^oVR
:
:.Vars
:^^oVR->->^^oShipX+2->^^oXVel+2->->^^oShipLaser+2->->^^oLaserX+2->->^^oLaserY+2->->^^oCollision+2->->^^oAlienDir+2->->^^oAlienX
:0->XVel->ShipLaser->LaserX->LaserY->Collision->AlienX+1->AlienDir+43->ShipX
:0->theta->T->F
:
:fnInt(Tick,6)
:
:.Game loop
:Repeat getKey(15)??getKey(55)
: Input()
: Move()
: Fix()
: Draw()
:
: DispGraphClrDraw
:End
:
:.Fun\ctions
:Lbl Input
:.Move
:getKey(3)-getKey(2)->XVel
:
:.Laser
:If getKey(54)
: ShipFire()
:End
:Return
:
:Lbl Move
:If theta=2
: ShipX+XVel->ShipX:0->theta
: Else
: theta++
:End
:
:If ShipX>99
: 0->ShipX
:End
:
:If ShipX>88
: 88->ShipX
:End
:
:If ShipLaser?theta=1
: LaserY--
:End
:
:If LaserY<<~7
: 0->ShipLaser
:End
:Return
:
:Lbl ShipFire
:!If ShipLaser
: 1->ShipLaser
: ShipX->LaserX
: 56->LaserY
:End
:Return
:
:Lbl Fix
:.Laser
:For(I,0,2)
: Collide(I*32+3,47,I*32+21,49,LaserX,LaserY)
: If Collision?{I+GDB0}?ShipLaser
: 0->Collision
: 0->ShipLaser
:
: !If {I+GDB0}>2??{I+GDB0}==0
: {I+GDB0}++
: Else
: 0->{I+GDB0}
: End
: End
:End
:0->Collision
:Return
:
:Lbl Collide
:If [r5]>[r1]?[r5]<[r3]?[r6]>[r2]?[r6]<[r4]
: 1->Collision
: Else
: 0->Collision
:End
:Return
:
:Lbl Draw
:.Ship
:Pt-On(ShipX,56,Pic0Ship)
:
:.Laser
:If ShipLaser
: Pt-On(LaserX,LaserY,Pic0Lasr)
:End
:
:.Shields
:For(I,0,2)
: If {I+GDB0}
: Pt-On(I*32+8,48,{I+GDB0}-1*16+Pic0Shld)
: Pt-On(I*32+16,48,{I+GDB0}-1*16+Pic0Shld+8)
: End
:End
:
:.Aliens
:For(Y,0,3)
: For(X,0,6)
:
: Pt-On(AlienX+{X+GDB0X},{Y+GDB0Y},F*8+Pic0Alen)
: If AlienX+{X+GDB0X}=88:~1->AlienDir:End
: If AlienX+{X+GDB0X}=0:1->AlienDir:End
: End
:End
:
:Return
:
:Lbl Tick
:T++
:
:If T=100
: If F
: 0->F
: Else
: 1->F
: End
: 0->T
: AlienX+AlienDir->AlienX
:End
:
:Return
:
:LnReg^^r
:ClrHome
:
:#Icon(00005E806D8033007F8052B000300830043008000400003000FC01FE01FE01FE)
:DiagnosticOff
:
:.Ship
:[000000187EFFFFFF]->Pic0Ship
:
:.Shields
:[0000007FFFFCF0E0]->Pic0Shld
:[000000FEFF3F0F07]
:[0000007F00FCF0E0]
:[000000FE003F0F07]
:[0000007F00FC00E0]
:[000000FE003F0007]
:
:.Aliens
:[000000BDDB66FFA5]->Pic0Alen
:[0000003C7EDBE7BD]
:
:.Lasers
:[0000000018181818]->Pic0Lasr
:[0000000008100810]
:[0000000010081008]
:
:.Shields map
:Data(1,1,1)->GDB0
:1->{GDB0}->{1+GDB0}->{2+GDB0}
:
:.Alien position
:Data(8,20,32,44,56,68,80)->GDB0X
:Data(2,10,18,26)->GDB0Y
:
:.Variable RAM
:|E9872->->^^oVR
:
:.Vars
:^^oVR->->^^oShipX+2->^^oXVel+2->->^^oShipLaser+2->->^^oLaserX+2->->^^oLaserY+2->->^^oCollision+2->->^^oAlienDir+2->->^^oAlienX
:0->XVel->ShipLaser->LaserX->LaserY->Collision->AlienX+1->AlienDir+43->ShipX
:0->theta->T->F
:
:fnInt(Tick,6)
:
:.Game loop
:Repeat getKey(15)??getKey(55)
: Input()
: Move()
: Fix()
: Draw()
:
: DispGraphClrDraw
:End
:
:.Fun\ctions
:Lbl Input
:.Move
:getKey(3)-getKey(2)->XVel
:
:.Laser
:If getKey(54)
: ShipFire()
:End
:Return
:
:Lbl Move
:If theta=2
: ShipX+XVel->ShipX:0->theta
: Else
: theta++
:End
:
:If ShipX>99
: 0->ShipX
:End
:
:If ShipX>88
: 88->ShipX
:End
:
:If ShipLaser?theta=1
: LaserY--
:End
:
:If LaserY<<~7
: 0->ShipLaser
:End
:Return
:
:Lbl ShipFire
:!If ShipLaser
: 1->ShipLaser
: ShipX->LaserX
: 56->LaserY
:End
:Return
:
:Lbl Fix
:.Laser
:For(I,0,2)
: Collide(I*32+3,47,I*32+21,49,LaserX,LaserY)
: If Collision?{I+GDB0}?ShipLaser
: 0->Collision
: 0->ShipLaser
:
: !If {I+GDB0}>2??{I+GDB0}==0
: {I+GDB0}++
: Else
: 0->{I+GDB0}
: End
: End
:End
:0->Collision
:Return
:
:Lbl Collide
:If [r5]>[r1]?[r5]<[r3]?[r6]>[r2]?[r6]<[r4]
: 1->Collision
: Else
: 0->Collision
:End
:Return
:
:Lbl Draw
:.Ship
:Pt-On(ShipX,56,Pic0Ship)
:
:.Laser
:If ShipLaser
: Pt-On(LaserX,LaserY,Pic0Lasr)
:End
:
:.Shields
:For(I,0,2)
: If {I+GDB0}
: Pt-On(I*32+8,48,{I+GDB0}-1*16+Pic0Shld)
: Pt-On(I*32+16,48,{I+GDB0}-1*16+Pic0Shld+8)
: End
:End
:
:.Aliens
:For(Y,0,3)
: For(X,0,6)
:
: Pt-On(AlienX+{X+GDB0X},{Y+GDB0Y},F*8+Pic0Alen)
: If AlienX+{X+GDB0X}=88:~1->AlienDir:End
: If AlienX+{X+GDB0X}=0:1->AlienDir:End
: End
:End
:
:Return
:
:Lbl Tick
:T++
:
:If T=100
: If F
: 0->F
: Else
: 1->F
: End
: 0->T
: AlienX+AlienDir->AlienX
:End
:
:Return
:
:LnReg^^r
:ClrHome