Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 09:17 01 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

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 States
Posts: 261
Posted: 10:27pm 21 Jul 2020
Copy link to clipboard 
Print this post

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 States
Posts: 3378
Posted: 10:40pm 21 Jul 2020
Copy link to clipboard 
Print this post

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 States
Posts: 261
Posted: 10:53pm 21 Jul 2020
Copy link to clipboard 
Print this post

  lizby said  Just as long as you don't make it on I85 through downtown Atlanta. Turtle graphics might be appropriate for that.


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: Canada
Posts: 1132
Posted: 11:34pm 21 Jul 2020
Copy link to clipboard 
Print this post

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 States
Posts: 261
Posted: 11:37pm 21 Jul 2020
Copy link to clipboard 
Print this post

  vegipete said  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.


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: Canada
Posts: 1132
Posted: 12:32am 22 Jul 2020
Copy link to clipboard 
Print this post

  mkopack73 said  Does it wrap around (ie, what drops off the bottom automatically rolls around to the top)?

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 States
Posts: 261
Posted: 01:31am 22 Jul 2020
Copy link to clipboard 
Print this post

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 States
Posts: 351
Posted: 04:20am 22 Jul 2020
Copy link to clipboard 
Print this post

  lizby said  Just as long as you don't make it on I85 through downtown Atlanta. Turtle graphics might be appropriate for that.


Ain't that the truth! :)
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025