This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2013-03-29 05:00:15

Imaginos
New Scratcher
Registered: 2013-03-06
Posts: 56

Help needed with my first game.

Hi scratchers. Ive only been using Scratch for a few weeks, so I've still got a lot to learn.
I have tried making a time trial car racing game (one player) based on the Marble Race game that comes as an example script.
The problem I'm having is that I want to change the stage to the next race track (I have three tracks at the moment) when the car crosses the finish line. I have tried putting an orange spot on the hood of the car and a yellow line at the back of the start/finish line but I can't seem to get Scratch to sense it.

Can anyone help?

Offline

 

#2 2013-03-29 05:09:16

Imaginos
New Scratcher
Registered: 2013-03-06
Posts: 56

Re: Help needed with my first game.

Here's the link...

http://scratch.mit.edu/projects/Imaginos/3218581

Offline

 

#3 2013-03-29 06:03:38

Sellout
Scratcher
Registered: 2013-03-28
Posts: 500+

Re: Help needed with my first game.

Okay, I think I solved it. I uploaded my updated version here but if you're interested in scripting yourself here's just the description of what I did:


Added a transparent sprite that you pass about midway through all tracks and a variable that detects if you've made it there or not. When you pass the finish line, it knows you're done and that it's time to switch because the variable I made tells it that you've made it to the checkpoint and back to the finish line (So it doesn't say the time repeatedly at the beginning too). So once you finish a race, it resets the variable that tracks if you've made it to the check point, since you haven't made it there this time around yet

Also made the grass have to wait a second after lowering your speed and making a noise, because it got really spastic without a wait


I would rather be alone than pretend I feel alright

Offline

 

#4 2013-03-29 06:10:12

Imaginos
New Scratcher
Registered: 2013-03-06
Posts: 56

Re: Help needed with my first game.

Thanks Sellout. I managed to find my own solution by simply associating the colour detection routine with the car sprite insted of the finish line sprite.

Offline

 

#5 2013-03-29 06:12:33

Sellout
Scratcher
Registered: 2013-03-28
Posts: 500+

Re: Help needed with my first game.

That makes sense too  tongue


I would rather be alone than pretend I feel alright

Offline

 

#6 2013-03-29 06:13:59

Imaginos
New Scratcher
Registered: 2013-03-06
Posts: 56

Re: Help needed with my first game.

I think that I'll have a go at making a variable to count laps so that I can tell it to only change tracks once 3 laps have been completed... or would it be better to only change if a target time is reached?

Offline

 

#7 2013-03-29 06:21:10

Sellout
Scratcher
Registered: 2013-03-28
Posts: 500+

Re: Help needed with my first game.

I think three laps a track is a good idea. Another thing you could do is maybe record all of the times with a list, using the green "join" block to combine a variable that keeps track of the track number with what the timer says. So you'd set the variable to "Track (#):" or something depending on which it was on, and it'd add "Track 1: 36" to the list if you took 36 seconds on track one!

Though that might look a little bulky on the screen, I guess


I would rather be alone than pretend I feel alright

Offline

 

#8 2013-03-29 06:49:50

Imaginos
New Scratcher
Registered: 2013-03-06
Posts: 56

Re: Help needed with my first game.

Thanks for the ideas Sellout.

Offline

 

#9 2013-03-30 21:46:55

shivadas
Scratcher
Registered: 2010-02-06
Posts: 100+

Re: Help needed with my first game.

Hi! Welcome to Scratch!  smile  Here's the way I would do it (assume the finish line is yellow):

Script for Car

when gf clicked
forever if (touching color [Yellow] ?)
broadcast [Next Track v]
end
Script for Stage

When I receive [Next Track v]
switch to background [Next Track v]
Hope that helps! Happy Scratching!

Last edited by shivadas (2013-03-30 21:47:22)


Please check out my latest project, Hunger Avenger!

Offline

 

Board footer