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

#1 2012-10-21 12:08:27

Borrego6165
Scratcher
Registered: 2011-03-10
Posts: 1000+

City Game Engine: Laying Roads

Currently in Generation:4001 you lay a piece of road down. Here is what is does:

1) It detects what location the player placed it.
2) It works out whether the spot exists (so has it been placed on the map?)
3) It sees what number that area it is.
Each tile on the map has a number. For this example, 1 will be grass, 2 will be a piece of road and 3 will be an obstacle.
4) If the area number is 1, it will place the road. If it equals 2 or 3, it will say "cannot place".

Now if you want a long piece of road, you have to place it on every individual tile. I need it to allow the player to drag the road tile along a line, preferably following the structure mentioned above.


Generation:4001 Build a beautiful city, with over 50 objects and over 10000 tiles per city! This simulates traffic, pollution, tourism, crime and more!

Offline

 

#2 2012-10-22 11:50:23

Borrego6165
Scratcher
Registered: 2011-03-10
Posts: 1000+

Re: City Game Engine: Laying Roads

anyone? i need a script for laying and dragging roads.


Generation:4001 Build a beautiful city, with over 50 objects and over 10000 tiles per city! This simulates traffic, pollution, tourism, crime and more!

Offline

 

#3 2012-10-22 13:30:06

Zarule6
New Scratcher
Registered: 2012-08-02
Posts: 36

Re: City Game Engine: Laying Roads

hmm  hmm  maybe you can use



when gf clicked
set(_counter_manager v) to [1]
set(_counter2 v)to [2]
set(_counter3 v)to [3]

Forever
Go to [mouse-pointer v]
set (x v) to (x position)
set (y v) to (y position)
  add (x) to [X-position v]
  add (y) to [y-position v]
   if (Mouse down?)
go to x:(item(set_counter_manager) of [X-position v]) y:(item(set_counter2) of [Y-Position v]
stamp
if <<(item(set_counter3) of (x-position)=[0]> or < (item(set_counter3) of [x-position v]>[0] >
  change (_counter_manager) by [1]
   else
if <<(item(set_counter3) of [x-position v]=[-1]> or <(item(set_counter3) of [x-position v] <[0]>
change (_counter_manager) by [-1]
if <<(y-position)=[0] >< or >[0] >>
  change set_counter2 by [1]
   else
if (item(set_counter3) of [y-position v]=-1 or (item(set_counter3) of [y-position v] <0
change (set_counter2) by [-1]
change (set counter) 3 by [1]
  else
if z key pressed
delete (all v) of [X-position v]
delete (all v) of [Y-position v]

(couldn't get the sratchblocks right since it kept cutting some parts out :? ) Hope this helps you in some way !  smile  or gives you some idea  hmm

Offline

 

#4 2012-10-22 13:43:20

Borrego6165
Scratcher
Registered: 2011-03-10
Posts: 1000+

Re: City Game Engine: Laying Roads

could you re-write it but with notes? I really am confused by it  tongue


Generation:4001 Build a beautiful city, with over 50 objects and over 10000 tiles per city! This simulates traffic, pollution, tourism, crime and more!

Offline

 

#5 2012-10-24 14:41:32

Zarule6
New Scratcher
Registered: 2012-08-02
Posts: 36

Re: City Game Engine: Laying Roads

Zarule6 wrote:

hmm  hmm  maybe you can use




when gf clicked
set(_counter_manager v) to [1]  //this is used to determine all of the values if I remember correctly  tongue  useing the diffrent variables to manage the lists to know the order in which to stamp etc.
set(_counter2 v)to [2]
set(_counter3 v)to [3]

if G key pressed    //command used to say you want to place the road
switch to costume dirt,tar etc.   //type of road you want(material)
Forever
Go to [mouse-pointer v]
set (x v) to (x position)     //this will keep tab of the position and update it automatically
set (y v) to (y position)
  add (x) to [X-position v]  //this will add the position to the stamping line which the user wants
  add (y) to [y-position v]
   if (Mouse down?)      //this is the action to give the command to start stamping the road etc.
go to x:(item(set_counter_manager)) of [X-position v]) y:(item(set_counter2)) of [Y-Position v]   //data being proccessed for the stamping order,calculations being made of which is to be stamped and where etc/
stamp
if <<(item(set_counter3) of (x-position)=[0]> or < (item(set_counter3) of [x-position v]>[0] >
  change (_counter_manager) by [1]
   else
if <<(item(set_counter3) of [x-position v]=[-1]> or <(item(set_counter3) of [x-position v] <[0]>
change (_counter_manager v) by [-1]
if <<(y-position)=[0] >< or >[0] >>
  change (set_counter2 v) by [1]
   else
if (item(set_counter3) of [y-position v]=-1 or (item(set_counter3) of [y-position v] <0
change (set_counter2 v) by [-1]   
change (set counter3 v) by [1]
  else
if z key pressed  //command used to clear the road wanted.
delete (all v) of [X-position v]
delete (all v) of [Y-position v]

(couldn't get the sratchblocks right since it kept cutting some parts out :? ) Hope this helps you in some way !  smile  or gives you some idea  hmm

Hope this helps ya out xD (yet again I fail to turn the code into scracthblocks so sad v.v )

If you want I can make an example of the code in scratch and upload it or send it to ya via skype ?  hmm

Offline

 

#6 2012-10-24 15:42:01

Borrego6165
Scratcher
Registered: 2011-03-10
Posts: 1000+

Re: City Game Engine: Laying Roads

Zarule6 wrote:

Zarule6 wrote:

hmm  hmm  maybe you can use




when gf clicked
set(_counter_manager v) to [1]  //this is used to determine all of the values if I remember correctly  tongue  useing the diffrent variables to manage the lists to know the order in which to stamp etc.
set(_counter2 v)to [2]
set(_counter3 v)to [3]

if G key pressed    //command used to say you want to place the road
switch to costume dirt,tar etc.   //type of road you want(material)
Forever
Go to [mouse-pointer v]
set (x v) to (x position)     //this will keep tab of the position and update it automatically
set (y v) to (y position)
  add (x) to [X-position v]  //this will add the position to the stamping line which the user wants
  add (y) to [y-position v]
   if (Mouse down?)      //this is the action to give the command to start stamping the road etc.
go to x:(item(set_counter_manager)) of [X-position v]) y:(item(set_counter2)) of [Y-Position v]   //data being proccessed for the stamping order,calculations being made of which is to be stamped and where etc/
stamp
if <<(item(set_counter3) of (x-position)=[0]> or < (item(set_counter3) of [x-position v]>[0] >
  change (_counter_manager) by [1]
   else
if <<(item(set_counter3) of [x-position v]=[-1]> or <(item(set_counter3) of [x-position v] <[0]>
change (_counter_manager v) by [-1]
if <<(y-position)=[0] >< or >[0] >>
  change (set_counter2 v) by [1]
   else
if (item(set_counter3) of [y-position v]=-1 or (item(set_counter3) of [y-position v] <0
change (set_counter2 v) by [-1]   
change (set counter3 v) by [1]
  else
if z key pressed  //command used to clear the road wanted.
delete (all v) of [X-position v]
delete (all v) of [Y-position v]

(couldn't get the sratchblocks right since it kept cutting some parts out :? ) Hope this helps you in some way !  smile  or gives you some idea  hmm

Hope this helps ya out xD (yet again I fail to turn the code into scracthblocks so sad v.v )

If you want I can make an example of the code in scratch and upload it or send it to ya via skype ?  hmm

nah you've done enough, I'll can pretty much use this now! thanks!


Generation:4001 Build a beautiful city, with over 50 objects and over 10000 tiles per city! This simulates traffic, pollution, tourism, crime and more!

Offline

 

Board footer