How would i be able to make a tumbleweed randomly go across the screen at different times and different directions?
I would guess that using the AGS CCS module and using characters to go across the screen.
I would probably make the tumble weed a character (unless you only need it for one room) and then put a random timer in repeatedly_execute calling a custom function;
//in Global Script
function get_tumbleweed(int whichway) {
if (whichway=1) { //the tumbleweed travels from left to right
Ã, ctumbleweed.changeroom(player.room, 0, 100);
Ã, ctumbleweed.walk(319, 100, enoblock, anywhere); //send it off screen
}
else { //the tumbleweed travels from right to left
Ã, ctumbleweed.changeroom(player.room, 320,100);
Ã, ctumbleweed.walk(0,100, enoblock, anywhere); //get it offscreen
}
//in script header
import function get_tumbleweed(int whichway)
//When player enters room
settimer(4, random(400)+200); //randomly sends the tumble weed along between 5-10 seconds after they enter the room
//in repeatedly_execute
if (istimerexpired(4)==1) {
get_tumbleweed(random(1));//randomly chooses one or zero
settimer(4,random(400)+200);// resets timer for tumbleweed to come in between 5-10 seconds
}
I'm not at a computer with ags so I haven't tested it or anything and it needs proper capitalization, but that's what I'd do.
good luck,
visionmind
Thanks that worked except when I the tumbleweed goes off one end it comes off the other end right away.
Here's my approach:
bool weed_moving=false;
bool wind_changes=true;
int wind_from_right=0;
function startWeed() {
if (wind_changes && Random(1)) wind_from_right=1-wind_from_right; // change wind dir
// set starting position
cTumble.x=wind_from_right*330-5;
cTumble.y=Random(50)+20;
cTumble.room=player.room;
weed_moving=true;
}
function moveWeed() {
cTumble.x=cTumble.x+Random(2)-wind_from_right*4+1;
cTumble.y=cTumble.y+Random(3)-1;
}
#sectionstart room_b // DO NOT EDIT OR REMOVE THIS LINE
function room_b() {
// script for Room: Repeatedly execute
if (IsTimerExpired(1)) {
if (!weed_moving) startWeed();
else moveWeed();
if (cTumble.x<-10 || cTumble.x>330 || cTumble.y>240) { // weed left room?
weed_moving=false;
SetTimer(1, 40*(Random(2)+1)); // pause for 1 to 3 seconds
}
else SetTimer(1, 4); // pause for 0.1 seconds before moving weed again
}
}
#sectionend room_b // DO NOT EDIT OR REMOVE THIS LINE
The tumbleweed doesn't move in a straight line and the pause can be adjusted freely.