Path: chuka.playstation.co.uk!news From: rs108@mdx.ac.uk (Robert Swan) Newsgroups: scee.yaroze.beginners Subject: Re: Plotting 2D Boxes in a 3D World Date: Sat, 16 May 1998 16:13:11 GMT Organization: PlayStation Net Yaroze (SCEE) Lines: 70 Message-ID: <355db8b0.377766@www.playstation.co.uk> References: <355a3dc2.2999054@news.playstation.co.uk> <355A67EA.137C@mdx.ac.uk> <355b5c8b.297920@news.playstation.co.uk> NNTP-Posting-Host: stu-dialup15.mdx.ac.uk X-Newsreader: Forte Free Agent 1.11/32.235 One of the things I mean to do in the very near future was do my own starfield routine, but once again I got beaten to it. (or should I say I wanted to do it, but was too lazzy, and seeing someone else do it made me feel stupid!). There are ways you can edit your routine to avoid one of the 'problems' of your routine, which is that you only have planes of stars, ie, a load moving a one pixel per update, the next lot at two, three or four or whatever. (you may want this effect...) To make every star move at its own speed then you have a scaled system which involves bit shifting. (I agree with James Shaughnessy, bit shiufting rules the world). ok, I will implement a demo of this myself at some point, starfields being very useful, but it goes something like this - Original method (stars move single pixel values only) typedef struct { long x, y; long dx, dy; } star; // where x,y = real screen coords // dx, dy = movement values in pixels stardemo.x += stardemo.dx; stardemo.y += stardemo.dy; // and then use a routine to draw the star, ie - drawStar(stardemo.x stardemo.y); OK, nice new version, which scales everything up by 256 times... typedef struct { long x, y; long dx, dy; } newstar; // where x,y = real screen coords * 256 // dx, dy = movement values in pixels * 256 stardemo.x += stardemo.dx; stardemo.y += stardemo.dy; // and then use a routine to draw the star, ie - drawStar(stardemo.x >> 8, stardemo.y >> 8); what this means is that if dx or dy = 256, then when it comes to drawing them on screen, they will still only have moved one pixel. With this method you can have dx or dy as, say, 255, which means that they will be a tiny bit slower than normal. Um, maybe this isnt clear so much now...! I use this method in my revolution game (on the 3rd + 4th levels, if you can get there) and I think scaling systems are explained a lot better on James Rutherford's page under the resource link - check out http://www.netyaroze-europe.com/~mrfrosty which is where I learnt about them. Robert Swan rs108@mdx.ac.uk http://www.netyaroze-europe.com/~middex2