Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI-Nspire => Topic started by: Matrefeytontias on October 05, 2012, 02:52:54 am

Title: [C] SpeedX 3D reaches your Nspire !
Post by: Matrefeytontias on October 05, 2012, 02:52:54 am
Hi guys !

I'm working on my first real Ndless project in C, a port of the mobile game SpeedX 3D !

In this game, you're a ship, a man or whatever (in any case, you don't see yourself) trapped in a tunnel, and you have to run (or fly, if you're a ship ;D ) while avoiding blocks which are in the tunnel. Why are there blocks here ? Who knows ... :evillaugh:

It's the really beginning of the project, but I've already done a great part, I meant the 3D tunnel effect !

(http://mattias.refeyton.fr/espace-ti/speedx3d/3dTunnelAlone.gif)

There is still this moiré I have to remove ...

Share comments, I'll update the thread often  ! ;)

For now it only works on non-CX calcs !!!
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: Stefan Bauwens on October 05, 2012, 02:57:27 am
Hey, good luck with this. If I'm not mistaken Nick was doing a port also once. But I think it wasn't in tunnel view.
Looks nice so far.
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: DJ Omnimaga on October 05, 2012, 03:51:27 am
Wow looks great! Is it the same game as on the iPod Touch? If so, you should make the background and circles the same color tints (blue) :D
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: Matrefeytontias on October 05, 2012, 04:11:00 am
As I said, for now it's only for non-CX calcs -> no colors D:
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: annoyingcalc on October 05, 2012, 11:00:28 am
Dang,but LOOKIN AWSOME
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: Chockosta on October 05, 2012, 11:41:34 am
Wow, it looks great !
I see you've resolved your problem with look-up tables :)
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: Matrefeytontias on October 05, 2012, 12:01:21 pm
Yeah, and I can say that the tutorial I used (Ben Ryves's one) is nearly wrong :P
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: nikitouzz on October 05, 2012, 01:00:30 pm
matref the z80 won already :p

no forget the axe and the hexa ;)
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: Matrefeytontias on October 05, 2012, 01:02:04 pm
I hadn't planned so ;D
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: Wayne on October 05, 2012, 01:22:30 pm
Nice work :thumbsup:
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: Hayleia on October 05, 2012, 01:28:47 pm
As I said, for now it's only for non-CX calcs -> no colors D:
But can't you use the function that looks like "lcd_ingray" (I don't code in C for Nspire so I don't know the exact formulation of the fucntion :P) to make it work on both calcs ?
In fact I don't even know what that command would do but I feel like this would work :P
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: Matrefeytontias on October 05, 2012, 01:45:24 pm
Oh yeah, I didn't think of it :D I'll use it.
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: cyanophycean314 on October 05, 2012, 10:00:56 pm
The name of this program is very similar to Nick's program, but I guess it's a different game. It does look really nice right now! Keep up the good work!
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: tr1p1ea on October 05, 2012, 10:04:12 pm
Are you drawing 1 corner and then mirroring?
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: Matrefeytontias on October 06, 2012, 04:08:43 am
Nope, I'm drawing the whole scene with
Code: [Select]
for(y = 0; y < 240; y += 2)
{
  for(x = 0; x < 240; x += 2)
  {
    ...
    setPixelBuf(screen, x+40, y, color);
    setPixelBuf(screen, x+41, y, color);
    setPixelBuf(screen, x+40, y+1, color);
    setPixelBuf(screen, x+41, y+1, color);
  }
}

@cyanophycean314 in fact it's the same game, but in Lua and because of the huge amount of calculations Nick choosed to make it plane when in C I choosed to make it a tunnel :)
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: flyingfisch on October 06, 2012, 12:08:16 pm
hmmm, i should try porting this to LuaFX and LuaZM...
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: Matrefeytontias on October 06, 2012, 12:31:55 pm
It'll be very hard in fact :/ I first did it in Lua, in a proof of concept, and it ran at 0.125 FPS ^^'
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: flyingfisch on October 06, 2012, 02:59:30 pm
How does your 3D routine work?

I thought I would do it like this:

1. draw lines.
2. draw circles.
3. draw obstacles.
4. collision detection

I would not be making it really 3D, it would be pseudo 3D.
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: Matrefeytontias on October 06, 2012, 03:46:22 pm
It's pseudo-3D based on angles and depths. I followed this tutorial by Ben Ryves (http://www.benryves.com/tutorials/tunnel/), but it appears that several concepts are wrongs (like the calculation of the depth, he use a really weird way to do this and I had a hard time to make it work).

You can of course ask questions if you're in trouble :)
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: DJ Omnimaga on October 06, 2012, 05:07:24 pm
As I said, for now it's only for non-CX calcs -> no colors D:
Are you planning CX support in the near future, though? Because non-CX calcs are getting harder and harder to find in stores so your game would probably get fewer and fewer interest with the time. D:
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: Matrefeytontias on October 07, 2012, 02:27:06 am
Yeah, of course I planned to adapt it for CX calcs ;) I even planned to make it with colors.
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: Hot_Dog on October 07, 2012, 02:43:46 am
Looking great! :D
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: Matrefeytontias on October 07, 2012, 03:26:09 am
Small update :)

In fact I just moved the origin up to make the player run on the ground instead of fly at the middle of the tunnel. And I also changed the texture so it looks better on-calc, even if it's worse on an emulator.

(http://mattias.refeyton.fr/espace-ti/speedx3d/3dTunnelAloneShifted.gif)

Also, the screen is taken by a Ti-Nspire CX CAS emulator :D
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: Matrefeytontias on October 08, 2012, 01:32:53 pm
Up !

I'm having trouble with srand() ... If I try to use it, the program crashes without saying anything. Here is the way I use it :
Code: [Select]
int ... , *initRand = 0x90090000;      // IRQ timer location

// mallocs here

srand(*initRand);
I think that the program crashes here.

Idea anyone ?
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: lkj on October 08, 2012, 02:07:36 pm
This syscall doesn't work in the current ndless revision also for other people :-\ You might have to implement a random number function yourself.
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: Matrefeytontias on October 08, 2012, 02:31:08 pm
That's weird, I've already done a program using this func and it worked perfectly (but maybe it's thanks to nSDL ...).
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: lkj on October 08, 2012, 03:35:15 pm
It works on cx, but not on classic nspires.
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: Matrefeytontias on October 08, 2012, 03:37:24 pm
SpeedX doesn't work on anything, and my others works on both ???
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: lkj on October 08, 2012, 03:45:37 pm
Then just implement your own rand function, for example
Code: [Select]
static unsigned x;

void sxorrand(unsigned seed){
    x = seed;
}

unsigned xorrand() {
  x ^= x << 13;
  x ^= x >> 17;
  x ^= x << 5;
  return x;
}
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: Matrefeytontias on October 08, 2012, 03:50:09 pm
Yeah, good idea, I'll use it. Thanks a lot :)
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: Lionel Debroux on October 08, 2012, 04:02:28 pm
As for other random generator types, a LFSR with significant length (32 bits), initialized with significant entropy (preferably > 10 bits), can yield good enough results without requiring division / modulo.
Several demos made by Thomas Nussbaumer for the TI-68k series, which I ported to the Nspire, use a LFSR written in C. My 127-byte "TV noise" demo, in 68000 ASM, also uses a LFSR for size constraints.
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: Matrefeytontias on October 13, 2012, 06:14:59 am
Update !

I added obstacles :thumbsup: well, for now they're inconsistents, but they're here ! ;D

(http://mattias.refeyton.fr/espace-ti/speedx3d/inconsistentsObstacles.gif)

(credits to lkj for the xorrand function)
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: AzNg0d1030 on October 13, 2012, 09:32:38 pm
How do you lose? I watched the screenie, and noticed that nothing happened even when the obstacles are in the middle :P
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: DJ Omnimaga on October 14, 2012, 03:00:40 am
How do you lose?

Losing The Game is IMPOSSIBLE?? O.O

Just kidding this looks kinda nice. Do you think in the grayscale version you can eventually add multiple shades of gray so it's no longer monochrome or would that hurt speed too much?
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: Matrefeytontias on October 14, 2012, 07:36:38 am
@AzNg0d1030 I just pressed ESC :P

@DJ_O I'll do that after removing the moiré, or you'll see an ugly grey curve coming to you from the center of the screen. And it doesn't hurt speed at all since grey are fully supported by the LCD.
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: AzNg0d1030 on October 14, 2012, 07:37:21 pm
@AzNg0d1030 I just pressed ESC :P

@DJ_O I'll do that after removing the moiré, or you'll see an ugly grey curve coming to you from the center of the screen. And it doesn't hurt speed at all since grey are fully supported by the LCD.
Ah so it isn't implemented yet? (Losing by hitting something)
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: DJ Omnimaga on October 14, 2012, 07:48:50 pm
What is a moiré? ???
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: Matrefeytontias on October 15, 2012, 01:23:58 am
@AzNg0d1030 not yet, but it's my next goal on my list ;)

@DJ_O a moiré is the ugly thing at the center of the screen, if you look well you'll see a cloud of dots which looks like nothing :P
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: Stefan Bauwens on October 15, 2012, 09:09:27 am
Maybe I should point out that there is a mistake in the topic title. it should be reaches and not reach if I'm not mistaken.

Also, looking good.
Title: Re: [C] SpeedX 3D reach your Nspire !
Post by: Matrefeytontias on October 15, 2012, 11:15:01 am
Oh my, you're right :P
/me the Frenchie riche iur enspirre
Title: Re: [C] SpeedX 3D reaches your Nspire !
Post by: apcalc on October 15, 2012, 05:48:42 pm
Looks good!  Great progress! ;)
Title: Re: [C] SpeedX 3D reaches your Nspire !
Post by: Matrefeytontias on October 16, 2012, 12:43:05 pm
Aaaw, look at this great update ! :D

I added consistent obstacles, 86 patterns for the blocks to spawn, and working collision detection !

(http://mattias.refeyton.fr/espace-ti/speedx3d/fullyImplementedObstacles.gif)

Now, it's fully playable and I've done the gameplay !

Here's what I planned to do :You can of course propose things :)
Title: Re: [C] SpeedX 3D reaches your Nspire !
Post by: lkj on October 16, 2012, 01:08:35 pm
What do you mean by "working collision detection"? I still don't die if I fall into an obstacle?
Also is it intended that the obstacles sometimes change their places when they're about five segments in front of you?

A highscore system would be cool :)
Title: Re: [C] SpeedX 3D reaches your Nspire !
Post by: AzNg0d1030 on October 16, 2012, 06:01:53 pm
What do you mean by "working collision detection"? I still don't die if I fall into an obstacle?
Also is it intended that the obstacles sometimes change their places when they're about five segments in front of you?

A highscore system would be cool :)
That's probably a bug. I guess you are supposed to lose when you hit an obstacle at the bottom of the screen :\
Title: Re: [C] SpeedX 3D reaches your Nspire !
Post by: Matrefeytontias on October 17, 2012, 02:04:03 am
@AzNg0d1030 That's not it ; in fact due to the way I display the obstacles they appear two times : one at a normal distance and one far away. So when the place of the obstacles you just avoided change, the place of the buggy obstacles changes too, even if they are far away. It'll be resolved when I'll remove the moiré.

@lkj no, I meant "collision detection works now" :P

And yeah, I planned highscore, I just forgot to write it ;D
Title: Re: [C] SpeedX 3D reaches your Nspire !
Post by: AzNg0d1030 on October 17, 2012, 08:02:28 pm
@AzNg0d1030 That's not it ; in fact due to the way I display the obstacles they appear two times : one at a normal distance and one far away. So when the place of the obstacles you just avoided change, the place of the buggy obstacles changes too, even if they are far away. It'll be resolved when I'll remove the moiré.

@lkj no, I meant "collision detection works now" :P

And yeah, I planned highscore, I just forgot to write it ;D
o.o got it understand now
Title: Re: [C] SpeedX 3D reaches your Nspire !
Post by: DJ Omnimaga on October 18, 2012, 12:55:36 am
Looks very great. Does it get more and more challenging as the game progress?
Title: Re: [C] SpeedX 3D reaches your Nspire !
Post by: Matrefeytontias on October 18, 2012, 01:47:48 am
Nope, I won't do that. In fact, what I planned is making 4 different levels, which are 4 different speeds.
Title: Re: [C] SpeedX 3D reaches your Nspire !
Post by: AzNg0d1030 on October 18, 2012, 09:41:36 pm
Nope, I won't do that. In fact, what I planned is making 4 different levels, which are 4 different speeds.
That sounds great!
Title: Re: [C] SpeedX 3D reaches your Nspire !
Post by: Matrefeytontias on September 11, 2013, 11:45:23 am
Über-super-hyper-giga-necro post of hell of death of darkness :w00t:

After one year, I finally decided to resume this. Since I currently have no real project for Nspire (nRayC isn't a "real" project), I decided to take this out of the garage and work back on it.

For now, the only thing I did was to port it to nSDL (which makes work with pixels faster and cross-platform), speed up the game a bit and shrink the space between obstacles (so now it's actually a bit challenging :P).

Also, I'm lacking ideas to make the game interesting (let's be honest, it's not very funny atm). I want to add bonuses in form of different textures for the tunnel (for example, a yellow sector will give you a shield which will permit you to take one damage before dying) and penalties in form of sectors you can't avoid (for example, your vision will be shrink).

By "sector", I mean the lines you fly on, that goes forward. Not sure if you get it, but the tunnel is divided in 8 sectors, on which there can be an obstacle, a bonus or just nothing.
Title: Re: [C] SpeedX 3D reaches your Nspire !
Post by: Eiyeron on September 11, 2013, 12:02:46 pm
Add some nice visuals, like earthquake, or color palette swap (change palette), trippy visuals for a real psychedelic experience!
Title: Re: [C] SpeedX 3D reaches your Nspire !
Post by: Matrefeytontias on September 11, 2013, 01:48:03 pm
Now that I think of it, this game is based on SpeedX3D for Android and iOS, so I'll try to include as much elements of the original game as possible in the port before starting anything else :P
Title: Re: [C] SpeedX 3D reaches your Nspire !
Post by: DJ Omnimaga on September 11, 2013, 02:34:30 pm
Looks very nice, but some suggestions: Add color and maybe make the sprites more detailed (like in Spenceboy98's Tunnel), and make the tunnel so that obstacles won't appear right in your face when the game starts, so you won't keep dying in less than  a second.

Also make it so the obstacles won't constantly changes position, because it's pretty random and you never know how to avoid them. Maybe make them so half a second before changing position, their new position is displayed in red or something, to warn you in advance.