Author Topic: Chunky Pixel Collision  (Read 22998 times)

0 Members and 1 Guest are viewing this topic.

Offline ervin

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.417
  • Country: au
    • index.php?action=treasury
  • Liked: 1110
  • Likes Given: 1320
Re: Chunky Pixel Collision
« Reply #150 on: 03:41, 04 June 12 »
Hi all.

Wow - has it really been 9 months since the last update?!?!?!
Holy cow...

Alrighty, work has (believe it or not) continued on this project.
I did have a quiet few months at the end of 2011, due to RealLife(tm).
But of course that itch is always in the back of a programmer's mind...

When I got my recent CPC6128 acquisition working, I was able to finally run my code on real hardware.
It was a wonderful, inspiring, and very proud moment, and the creative spark returned.  :)

I did a whole lot of work on the road routines, and then got stuck for several weeks trying to figure out how to translate it to pseudo-3D.  :-[

Then 2 nights ago, while laying in bed ready to go to sleep, an idea popped into my brain. I quietly crept out of bed so as to not wake my lovely wife, and got to work.

I now have a routine (on PC) that calculates raster positions (i.e. y coordinate) depending on an object's Z coordinate. These coordinates will be stored in a lookup table.

I had initially toyed with figures from actual perspective projections, and of course it looked realistic, but it just didn't feel "right" in the content of my game. I studied videos of Outrun, Space Harrier etc. etc. and realised that the sprite scaling calculations don't appear to be accurate  anyway! They have been scaled in order to create an illusion of movement and speed, rather than an illusion of 3D! (I could be wrong about this of course!)

Anyway, the routine I have now matches more closely the way those Sega games scaled their sprites.

In the last few weeks, I've also thrown away the scaling matrix lookup tables, which would have required quite a large amount of memory. Every width had to have its own scaling matrix (eg. the matrix for a 64-pixel wide sprite, for all scaling levels).

Instead I'm now calculating the scaling matrix for a sprite, once per frame, in real-time. It took several failed attempts, but I finally came up with a scaling routine that I was very happy with.

It is of course a little bit slower than simply looking up the scaling matrix, but it uses a heck of a lot less memory!
In fact the routine is very small, and in real usage (i.e. how fast the routine "feels"), there is no noticeable difference.
If I remember correctly, it takes just over half a second longer to render a screen-height sprite 100 times. I think that is an acceptable trade-off between speed and memory.  8)

Another benefit is that I can plug in new sprites much more easily now, as I don't need to go through the tedious process of pre-calculating the required scaling matrices.

So I now have a way to quickly determine the raster that a sprite should be sitting on, and which raster each strip of "road" should be allocated to. I've also got sprite scaling routines that I am very happy with, from both speed and "visual feel" terms.

Now to get something useful working!

Incidentally, a couple of weeks ago, I had almost committed to abandoning the idea of a 3D undulating road.
But now that idea is back, and hopefully I'll be able to implement it.
« Last Edit: 03:43, 04 June 12 by ervin »
My (cancelled) entry for the CPCRetroDev 2017 Competition http://www.cpcwiki.eu/forum/programming/my-cpcretrodev-2017-entry/
FAST line drawing in CPCtelera http://www.cpcwiki.eu/forum/programming/drawing-lines-with-cpctelera-sdcc/
RUNCPC My entry for the CPCRetroDev 2015 Competition http://www.cpc-power.com/index.php?page=detail&num=12494

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 16.399
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
  • Liked: 3714
  • Likes Given: 6632
Re: Chunky Pixel Collision
« Reply #151 on: 20:54, 04 June 12 »
Thanks for the update, really nice to see things are progressing and that that CPC of yours is going to be put to good use :)


Btw, I always keep a notepad at my bedside :)

Offline ervin

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.417
  • Country: au
    • index.php?action=treasury
  • Liked: 1110
  • Likes Given: 1320
Re: Chunky Pixel Collision
« Reply #152 on: 03:39, 05 June 12 »
Btw, I always keep a notepad at my bedside :)

Indeed the notepad would be the way to go... but I just couldn't let the idea wait.  8)
Tsk. Developers eh?
My (cancelled) entry for the CPCRetroDev 2017 Competition http://www.cpcwiki.eu/forum/programming/my-cpcretrodev-2017-entry/
FAST line drawing in CPCtelera http://www.cpcwiki.eu/forum/programming/drawing-lines-with-cpctelera-sdcc/
RUNCPC My entry for the CPCRetroDev 2015 Competition http://www.cpc-power.com/index.php?page=detail&num=12494

Offline ervin

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.417
  • Country: au
    • index.php?action=treasury
  • Liked: 1110
  • Likes Given: 1320
Re: Chunky Pixel Collision
« Reply #153 on: 05:49, 06 June 12 »
Alrighty, we have a working road now.
At last.
 
It doesn't undulate, or even bend or twist, but it does work.
Slowly.
 
It is frightfully slow at the moment, due to being completely unoptimised.
It's going to be a heck of a lot faster than this - I'm certain of it.
 
My (cancelled) entry for the CPCRetroDev 2017 Competition http://www.cpcwiki.eu/forum/programming/my-cpcretrodev-2017-entry/
FAST line drawing in CPCtelera http://www.cpcwiki.eu/forum/programming/drawing-lines-with-cpctelera-sdcc/
RUNCPC My entry for the CPCRetroDev 2015 Competition http://www.cpc-power.com/index.php?page=detail&num=12494

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 16.399
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
  • Liked: 3714
  • Likes Given: 6632
Re: Chunky Pixel Collision
« Reply #154 on: 15:32, 06 June 12 »
Well, with Winape in turbo mode it's fast....ish. Good job :)

Offline ervin

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.417
  • Country: au
    • index.php?action=treasury
  • Liked: 1110
  • Likes Given: 1320
Re: Chunky Pixel Collision
« Reply #155 on: 17:20, 06 June 12 »
 :laugh:

I'm actually using WinAPE's turbo mode to make testing bearable during this unoptimised phase.
Incidentally, I've already got it running quite a bit faster - and looking a bit different as well.
My (cancelled) entry for the CPCRetroDev 2017 Competition http://www.cpcwiki.eu/forum/programming/my-cpcretrodev-2017-entry/
FAST line drawing in CPCtelera http://www.cpcwiki.eu/forum/programming/drawing-lines-with-cpctelera-sdcc/
RUNCPC My entry for the CPCRetroDev 2015 Competition http://www.cpc-power.com/index.php?page=detail&num=12494

Offline ervin

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.417
  • Country: au
    • index.php?action=treasury
  • Liked: 1110
  • Likes Given: 1320
Re: Chunky Pixel Collision
« Reply #156 on: 04:52, 07 June 12 »
I've got the road code looking very different, and also running a heck of a lot faster now.
There is still lots more optimisation to do though, which is good as I ultimately want the road itself to have a negligible effect on framerate. The sprites will need as much cpu time as they can get.  8)
 
I also found a few bugs related to the way the road works depending on how fast the "player" is travelling. I think it is all ok now.
 
When the attached program loads, you'll be presented with 3 options: slow, medium and fast.
These don't refer to how fast the program runs.  :)
They refer to how fast the player travels.
 
In the game, the idea is for the player to be travelling FAST, with the other 2 speeds used to add interesting feedback to collisions.
« Last Edit: 05:07, 07 June 12 by ervin »
My (cancelled) entry for the CPCRetroDev 2017 Competition http://www.cpcwiki.eu/forum/programming/my-cpcretrodev-2017-entry/
FAST line drawing in CPCtelera http://www.cpcwiki.eu/forum/programming/drawing-lines-with-cpctelera-sdcc/
RUNCPC My entry for the CPCRetroDev 2015 Competition http://www.cpc-power.com/index.php?page=detail&num=12494

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 16.399
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
  • Liked: 3714
  • Likes Given: 6632
Re: Chunky Pixel Collision
« Reply #157 on: 10:46, 07 June 12 »

When the attached program loads, you'll be presented with 3 options: slow, medium and fast.
These don't refer to how fast the program runs.  :)
They refer to how fast the player travels.
 


This will teach me to read the description before loading the image :D
But why does the line travel slower, the higher it is on the screen? And what's with the colour scheme? :D

Offline ervin

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.417
  • Country: au
    • index.php?action=treasury
  • Liked: 1110
  • Likes Given: 1320
Re: Chunky Pixel Collision
« Reply #158 on: 13:28, 07 June 12 »
The colour scheme is something that isn't locked down yet.
I want to keep the moving lines quite subtle compared to the solid road, but the actual combination of colours is undecided.

The line speeds up as it moves down because it is actually moving towards you.
(Well, not really, but that's the illusion I'm trying to create. Think of it as a 3D road).
The "closer" it is to you, the faster it appears to move.
My (cancelled) entry for the CPCRetroDev 2017 Competition http://www.cpcwiki.eu/forum/programming/my-cpcretrodev-2017-entry/
FAST line drawing in CPCtelera http://www.cpcwiki.eu/forum/programming/drawing-lines-with-cpctelera-sdcc/
RUNCPC My entry for the CPCRetroDev 2015 Competition http://www.cpc-power.com/index.php?page=detail&num=12494

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 16.399
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
  • Liked: 3714
  • Likes Given: 6632
Re: Chunky Pixel Collision
« Reply #159 on: 14:35, 07 June 12 »
I know what you mean, but somehow it doesn't look convincing. I'd probably prefer it if they came at me at constant speed (depending on the actual "character"/"hero" speed of course)

Offline ervin

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.417
  • Country: au
    • index.php?action=treasury
  • Liked: 1110
  • Likes Given: 1320
Re: Chunky Pixel Collision
« Reply #160 on: 14:53, 07 June 12 »
It might be hard to imagine the effect I'm after, as there aren't any sprites racing towards you at the moment.
Once they are in, the effect might be more convincing.
I hope.  8)

I'm thinking that if the lines all came toward you at the same speed, it would just look like a vertical scroll.
In any case, I can adjust the speed of the line at every part of the road really easily, due to the way the routine is written.
« Last Edit: 14:55, 07 June 12 by ervin »
My (cancelled) entry for the CPCRetroDev 2017 Competition http://www.cpcwiki.eu/forum/programming/my-cpcretrodev-2017-entry/
FAST line drawing in CPCtelera http://www.cpcwiki.eu/forum/programming/drawing-lines-with-cpctelera-sdcc/
RUNCPC My entry for the CPCRetroDev 2015 Competition http://www.cpc-power.com/index.php?page=detail&num=12494

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 16.399
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
  • Liked: 3714
  • Likes Given: 6632
Re: Chunky Pixel Collision
« Reply #161 on: 14:25, 08 June 12 »
I see what you mean. Maybe I'm wrong, it's just that it doesn't quite feel... right. Indeed, who knows, maybe it makes sense in your hear because you know what's supposed to be going on in it in the end!

Offline ervin

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.417
  • Country: au
    • index.php?action=treasury
  • Liked: 1110
  • Likes Given: 1320
Re: Chunky Pixel Collision
« Reply #162 on: 14:41, 08 June 12 »
No matter what though, once I have some sprites moving toward the player as they race along the road, I'll certainly be open to suggestions.

Also, thanks for taking the time to give me feedback.
Feedback will get more and more important as development continues.
My (cancelled) entry for the CPCRetroDev 2017 Competition http://www.cpcwiki.eu/forum/programming/my-cpcretrodev-2017-entry/
FAST line drawing in CPCtelera http://www.cpcwiki.eu/forum/programming/drawing-lines-with-cpctelera-sdcc/
RUNCPC My entry for the CPCRetroDev 2015 Competition http://www.cpc-power.com/index.php?page=detail&num=12494

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 16.399
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
  • Liked: 3714
  • Likes Given: 6632
Re: Chunky Pixel Collision
« Reply #163 on: 15:35, 08 June 12 »
My pleasure, I really enjoy this progress :)