![]() |
Forum Index : Microcontroller and PC projects : What’s the best way to do this?
Author | Message | ||||
mkopack73 Senior Member ![]() Joined: 03/07/2020 Location: United StatesPosts: 261 |
As part of my experimentation I was planning to sit down and work with sprites a bit last night, which quickly devolved into trying to make a simple little racing/driving game. So what I have so far: * vertical oriented road with double yellow centerline and white edge lines *code to read the Wii classic controller to control the players car going left/right, with the right stick controlling speed * timing detection for the frame to put in appropriate delays to try to maintain a fixed 60hz rate * buffering by drawing to screen 1 then copying over at the end of the cycle I need to add in the player’s car and get that actually moving around. That’s tonight. What I’m stumped on is the right way to do the forward motion. I was planning to keep the player’s car vertically fixed about 1/3 up the screen and use the speed to control the drawing of the dashed lane lines - the faster the player is going, the more different they draw vertically offset from the previous frame to make it seem like more distance has been traveled and speed. Should I draw those using Thick Line commands? Or maybe 1 line command and then blitter copying to the other locations? Or maybe as tall sprites that can be shifted vertically? It’s a very repeating pattern. Is there a limit to the size of sprites? Thoughts? My plans for this are to try to make it into a full little game where you are racing to make it around the beltway of Atlanta (interstate 285) and there would be varying traffic you have to weave through, maybe sometimes you have to slow down to make a gap as cars in different lanes are going different speeds, maybe they will sometimes change lanes (so I can maybe put turn signals blinking on the AI car sprites), or there will be random debris on the road you have to dodge (I’ve seen everything from baby diapers to furniture to ladders to bumpers, to you name it on the road there in real life), and maybe have it where sometimes there is an overpass that you go under that blocks your view momentarily. Gotta try to get to the finish and get the best time possible. |
||||
lizby Guru ![]() Joined: 17/05/2016 Location: United StatesPosts: 3378 |
Just as long as you don't make it on I85 through downtown Atlanta. Turtle graphics might be appropriate for that. PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
mkopack73 Senior Member ![]() Joined: 03/07/2020 Location: United StatesPosts: 261 |
Lol well I was going to put in different difficulty levels that cause it to be done at different times of day - East mode - 1am, medium at 1pm, hard at 5pm, impossible when they president comes to town! |
||||
vegipete![]() Guru ![]() Joined: 29/01/2013 Location: CanadaPosts: 1132 |
I would think some vertical range of player's car would be good. The faster you go, the higher you go, maybe between 1/4 up and 1/2 or even 2/3. At higher speeds, you end up with less reaction time, much like the real world. There are 2 sprite commands that can be unexpectedly useful, even when not using sprites: SPRITE SCROLL delta_x, delta_y [,colour] SPRITE SCROLLR x, y, w, h, delta_x, delta_y [,colour] The difference is the first scrolls the entire screen, the second scrolls a rectangle of your choice. Visit Vegipete's *Mite Library for cool programs. |
||||
mkopack73 Senior Member ![]() Joined: 03/07/2020 Location: United StatesPosts: 261 |
Interesting, so I could draw the lines for the lanes once, and then use SCROLLR to move just those vertical regions downwards. Nice! Does it wrap around (ie, what drops off the bottom automatically rolls around to the top)? |
||||
vegipete![]() Guru ![]() Joined: 29/01/2013 Location: CanadaPosts: 1132 |
Yes, it can, if you so choose. The manual has details, including which sprites are 'stuck' to the scrolling part. So you could have signs and oil slicks, etc. Alternatively, later CMM2 firmware implements a frame buffer which can be bigger than the displayed screen. Presumably this bigger buffer could be scrolled too, so that the 'scroll window' is 2 or 3 screens high. Then things wouldn't repeat quite so frequently. Visit Vegipete's *Mite Library for cool programs. |
||||
mkopack73 Senior Member ![]() Joined: 03/07/2020 Location: United StatesPosts: 261 |
Yup found it. Thanks!! That has the lane dashed lines scrolling down now in conjunction with your speed (although I need to rethink the joystick routines a bit. It’s crazy hyper sensitive and goes from nothing to full speed and back too quickly.) Next to add in the player’s car sprite. And then maybe an AI car to avoid and do the collision detection and handling. |
||||
SimpleSafeName![]() Guru ![]() Joined: 28/07/2019 Location: United StatesPosts: 351 |
Ain't that the truth! :) |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |