August 09, 2020, 04:47:55 pm

You can help CodeWalrus stay online by donating here.

 WARNING: DO NOT UPGRADE your TI-83 Premium CE or TI-84 Plus CE to OS 5.5.1 and higher. It removes all compatibility with most games and removes ASM/C programming! DOWNGRADING IS IMPOSSIBLE. BE WARNED! Likewise, do NOT update your TI-Nspire CX past OS 4.5.0, else using Ndless and ASM/C programs will be impossible.

Started by Unicorn, April 04, 2015, 05:03:56 pm

0 Members and 1 Guest are viewing this topic.

#### Unicorn

##### June 19, 2015, 09:51:07 pm #105
Hmm..

I was using the xlibc spite collision, real(4,6 and I think that will work for me, if I can figure out how to get it to work without nesting it in an If Then End loop.

#### DJ Omnimaga

##### June 20, 2015, 03:40:59 am #106
Oh right, I forgot that xLIBC had sprite collision. I never got it to work before (which is why Reuben CSE died). Maybe @tr1p1ea could help since he wrote that part of DCSE but he isn't around often.

#### tr1p1ea

##### June 20, 2015, 02:06:51 pm #107
Brief explanation of sprite collision function, it tests for collisions between rectangular coordinates so if you have say a sprite that is:

X = 10
Y = 10
W = 8
H = 8

And you wanted to test if this 'rectangle' overlaps with an enemy sprite at:

X = 15
Y = 15
W = 8
H = 8

Like so:

Then you can use the function to check:

real(4,6,1,10,10,8,8,15,15,8,8

In which case they do collide so the result will be a list:

{1,1,0

{1 = collision found
1 = number of collisions found
0 = index of collision passed with real( statement

And since there was only 1 set of coordinates passed the first index that collided is 0 (the red square).

Another case:

Rectangles at:

X = 10
Y = 10
W = 8
H = 8

Tested against others where:

X = 15
Y = 15
W = 8
H = 8

X = 48
Y = 32
W = 16
H = 16

X = 8
Y = 0
W = 64
H = 16

Like so:

The call would be: real(4,6,3,10,10,8,8,15,15,8,8,48,32,16,16,8,0,64,16

And the result would be:

{1,2,0,2

{1 = collision found (would be 0 if no collisions occured)
2 = number of collisions found (green and red)
0 = collision with index 0 (red)
2 = collision with index 2 (green)

Index 1 is the orange square for which there was no collision.

#### Unicorn

##### June 20, 2015, 09:32:50 pm #108
Thanks for that info tr1p1ea! I think that may just make this whole thing work

#### DJ Omnimaga

##### June 25, 2015, 12:40:16 am #109
Ooh nice tutorial tr1p1ea. I think it should be on the DCS wiki somewhere. And glad to hear Unicorn.

#### Unicorn

##### June 25, 2015, 11:44:08 am #110
Yup! I just need to spend time testing and confirming that collision works, then its on to throwing the money

#### alexgt

##### June 25, 2015, 02:42:00 pm #111
Quote from: Unicorn on June 25, 2015, 11:44:08 am
Yup! I just need to spend time testing and confirming that collision works, then its on to throwing the money

And on to convincing my friend to let me borrow his CSE

#### Unicorn

##### July 03, 2015, 03:05:16 am #112
lol, well sprite collisions not working. So I think I'm not checking the list right, so I'm gonna try to fix that soon. Any good suggestions for commands that check lists? (I always have problems with them) :/

#### DJ Omnimaga

##### July 08, 2015, 03:29:09 am #113
I can't help unfortunately, since I myself had to quit Reuben CSE due to issues with collision D:. Maybe you could ask on Cemetech? Or maybe @tr1p1ea could help. You should post the code, though.

#### Unicorn

##### July 08, 2015, 12:49:10 pm #114 Last Edit: July 08, 2015, 01:13:24 pm by Unicorn
I'll try to post the code, but its a pain typing it all out

EDIT: Current Code, @tr1p1ea can you give me an idea of what I'm doing wrong with sprite collision?

`real(0,1,1real(8,1,0"MNYWBGreal(5,2,0"MNSPRTreal(5,0,0DelVar NDelVar BDelVar K19→TrandInt(8,19→UrandInt(5,15→VRepeat K=15real(2,0,0Ans→KT+1→TU+1→UV+1→VIf T=20:ThenLbl 1randInt(1,130→Mreal(4,6,2,M,1,16,16,L,1,16,16,N,1,16,16 //HEremax(|LXLIF Ans=2M+24->MIf Ans=1Goto 1real(4,0,M,1,3,3,0,0,4,0,0,0,1,2,8,9,10,16,17,18EndIf T≥40:ThenDelVar Treal(7,9,M,1,29,26,93,0EndIf U=20:ThenLbl 2randInt(1,130→Lreal(4,6,2,L,1,16,16,M,1,16,16,N,1,16,6 //Heremax(|LXLIF Ans=2L+24->LIf Ans=2Goto 2real(4,0,L,1,3,3,0,0,4,0,0,0,1,2,8,9,10,16,17,18EndIf U≥40:ThenDelVar Ureal(7,9,L,1,29,26,93,0EndIf V=20:ThenLbl 3randInt(1,130→Nreal(4,6,2,N,1,16,16,M,1,16,16,L,1,16,16 //Heremax(|LXLIF Ans=2N+24->NIf Ans=1Goto 3real(4,0,N,1,3,3,0,0,4,0,0,0,1,2,8,9,10,16,17,18EndIf V≥40:ThenDelVar Vreal(7,9,N,1,29,26,93,0EndIf K=2P-25→PIf K=3P+25→PIf K=2 or K=3:Then"MNYWBGreal(5,1,0real(5,3,P-25,104,16,16,0,0real(5,3,P+25,104,16,16,0,0Endreal(4,0,P,104,2,2,0,0,4,0,0,3,4,11,12End`

#### tr1p1ea

##### July 14, 2015, 04:43:24 am #115
Im looking into the issue, just wondering what the expected behaviour is?

#### Unicorn

##### July 14, 2015, 01:27:32 pm #116
The sprite x coord (L,M, and N) gets changed up 16 pixels when the collision is found

#### tr1p1ea

##### July 16, 2015, 01:08:31 am #117
So this will be between the sprites on the top row?

#### Unicorn

##### July 16, 2015, 01:19:16 am #118
Yeah, I made a few changes, so there's new code. It still didn't fix it though Thanks for looking at it.
`real(0,1,1real(8,1,0"MNYWBGreal(5,2,0"MNSPRTreal(5,0,0DelVar NDelVar BDelVar K19→TrandInt(8,19→UrandInt(5,15→VRepeat K=15real(2,0,0Ans→KT+1→TU+1→UV+1→VIf T=20:ThenLbl 1randInt(1,130→Mreal(4,6,2,M,1,16,16,L,1,16,16,N,1,16,16 //HEreIf max(|LXL=2 or max(|LXL=1Goto 1real(4,0,M,1,3,3,0,0,4,0,0,0,1,2,8,9,10,16,17,18EndIf T≥40:ThenDelVar Treal(7,9,M,1,29,26,93,0EndIf U=20:ThenLbl 2randInt(1,130→Lreal(4,6,2,L,1,16,16,M,1,16,16,N,1,16,6 //HereIf max(|LXL=2 or max(|LXL=1Goto 2real(4,0,L,1,3,3,0,0,4,0,0,0,1,2,8,9,10,16,17,18EndIf U≥40:ThenDelVar Ureal(7,9,L,1,29,26,93,0EndIf V=20:ThenLbl 3randInt(1,130→Nreal(4,6,2,N,1,16,16,M,1,16,16,L,1,16,16 //HereIf max(|LXL=2 or max(|LXL=1Goto 3real(4,0,N,1,3,3,0,0,4,0,0,0,1,2,8,9,10,16,17,18EndIf V≥40:ThenDelVar Vreal(7,9,N,1,29,26,93,0EndIf K=2P-25→PIf K=3P+25→PIf K=2 or K=3:Then"MNYWBGreal(5,1,0real(5,3,P-25,104,16,16,0,0real(5,3,P+25,104,16,16,0,0Endreal(4,0,P,104,2,2,0,0,4,0,0,3,4,11,12End`

#### Unicorn

##### August 10, 2015, 06:00:45 pm #119
BIG changes. So I've decided to revamp the game, making it into a kind of gathering game, with occasional enemies and a shop. So sort of like an RPG, but a bit different.

The original game idea seemed a bit boring, hence the change. And I'm going to change sprite sizes, or maybe have the game be full screen, but probably not.