von Daniel am 22.Dezember 96 um 15:39:49:
zu: Perlen aus dem Strom der Nachrichten im direct_L von Daniel am 22.Dezember 96 um 02:00:59:
Here is the correct code to get what you want:
property ballSprite, pH, pV property left, top, right, bottom on new me, listPosition set ballSprite = listposition puppetSprite ballSprite, 1 set pH = (item random(2) of "-1,1")*random(20) --random H vector set pV = (item random(2) of "-1,1")*random(20) --random V vector set h2 = (the height of sprite ballSprite) / 2 set w2 = (the width of sprite ballSprite) / 2 if the type of member the member of sprite ballSprite = #bitmap then -- the registration point is in the center set right = 640 - w2 set left = w2 set bottom = 480 - h2 set top = h2 else if the type of member the member of sprite ballSprite = #shape then -- the registration point is in the leftTop set right = 640 - the width of sprite ballSprite set left = 0 set bottom = 480 - the height of sprite ballSprite set top = 0 end if set the loc of sprite ballSprite = point(random(540)+50, random(380)+50) return me end on stepFrame me set h = the locH of sprite ballSprite set v = the locV of sprite ballSprite if h > right OR h < left then set pH = -pH end if if v > bottom OR v < top then set pV = -pV end if set the locH of sprite ballSprite = the locH of sprite ballSprite + pH set the locV of sprite ballSprite = the locV of sprite ballSprite + pV end
D. Plänitz