[Source] Shaking Window
Author |
Message |
Delos

|
Posted: Sat May 21, 2005 11:52 am Post subject: [Source] Shaking Window |
|
|
Here's a nifty little procedure. Replicates those much loved window-shakes (or nudges as some call them) that are seen in various chatting proggies.
Syntax:
shakeWindow (dx, dy, dur)
dx - how far left and right the window can move. Suggested: 1-5
dy - how far up and down the window can move. Suggested: 1-5
dur - duration. How long the window will shake for (in thousanths of a second. Suggested: 200-800.
The file has an example hardcoded at the end of it. To use, copy the proc into your source and call when needed. No need to specify which run window is being shaken, it automatically selects the active one. If you need to move between various windows (i.e., shake a window that is inactive, perhaps in the background), alter the source or PM me to set it up.
Description: |
|
 Download |
Filename: |
[Source] Shaking Window.t |
Filesize: |
1.41 KB |
Downloaded: |
449 Time(s) |
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
MysticVegeta

|
Posted: Sat May 21, 2005 11:55 am Post subject: (No subject) |
|
|
nice, Thats what i needed. thanks!
|
|
|
|
|
 |
[Gandalf]

|
Posted: Sat May 21, 2005 8:58 pm Post subject: (No subject) |
|
|
Very, very nice. Would you mind it if I also added this to my list of "potentally evil programs"? . But it has many good purposes too - thanks for the idea and program!
|
|
|
|
|
 |
Lazarus

|
Posted: Sat May 21, 2005 9:03 pm Post subject: (No subject) |
|
|
omg! thanks for reminding me, there's this song on ebaums world that uses a Java Script to do this.. Great song
dub dub dub
|
|
|
|
|
 |
Flikerator
|
Posted: Thu May 26, 2005 1:23 pm Post subject: (No subject) |
|
|
Just a thought, change the "a" to ""
Looks a bit better
Or print Shake! Shake! Diaganally? Just a thought : )
|
|
|
|
|
 |
Delos

|
Posted: Thu May 26, 2005 5:52 pm Post subject: (No subject) |
|
|
The "a" was just the first letter that I typed...it's just part of an example demonstrating how the syntax works.
Sure it would have been more descriptive...but meh, I wasn't feeling entirely creative at the time.
|
|
|
|
|
 |
Aziz

|
Posted: Wed Jun 08, 2005 1:25 pm Post subject: (No subject) |
|
|
That's pretty cool. Could be used for a cool game. Like so:
code: | % Example.
setscreen ("graphics:400;300,offscreenonly,position:center;truemiddle")
var endGame := false
var x, y, b : int
const CX := maxx div 2
const CY := maxy div 2
const CR := 25
procedure shakeWindow (dx, dy : int)
/* Parameters:
dx - how far left and right the window can move. Suggested: 1-5
dy - how far up and down the window can move. Suggested: 1-5
dur - duration. How long the window will shake for (in thousanths of a second. Suggested: 200-800.
*/
var tempX, tempY : int
var xNot, yNot : int
% Original positions, will be reassigned before termination.
Window.GetPosition (Window.GetActive, tempX, tempY)
Window.GetPosition (Window.GetActive, xNot, yNot)
% Assign values.
loop
exit when endGame
if tempX <= (xNot - dx) then
for i : 1 .. dx
tempX += 1
end for
elsif tempX >= (xNot + dx) then
for i : 1 .. dx
tempX -= 1
end for
else
for i : 1 .. dx
tempX += Rand.Int (-1, 1)
end for
end if
if tempY <= (yNot - dy) then
for i : 1 .. dy
tempY += 1
end for
elsif tempY >= (yNot + dy) then
for i : 1 .. dy
tempY -= 1
end for
else
for i : 1 .. dy
tempY += Rand.Int (-1, 1)
end for
end if
% Set bounds for x- and y-. Stops shake from moving too far away.
Window.SetPosition (Window.GetActive, tempX, tempY)
%Delay
delay (10)
View.Update
end loop
Window.SetPosition (Window.GetActive, xNot, yNot)
end shakeWindow
process shakeProcess (dx, dy : int)
shakeWindow (dx, dy)
end shakeProcess
process checkEnd
var key : string (1)
loop
exit when endGame
if hasch then
getch (key)
if ord (key) = 27 then
endGame := true
exit
end if
end if
end loop
end checkEnd
process mouseCheck
loop
exit when endGame
mousewhere (x, y, b)
end loop
end mouseCheck
put "Ready? Press any key when ready!"
put "[Hint: position mouse right now]"
put "[ESC to quit]"
drawfilloval (CX, CY, CR, CR, 7)
View.Update
Input.Pause
cls
fork checkEnd
fork mouseCheck
fork shakeProcess (25, 25)
loop
exit when endGame
locate (maxrow - 1, 1)
put "X: ", x ..
locate (maxrow, 1)
put "Y: ", y ..
drawfilloval (CX, CY, CR, CR, 7)
View.Update
if sqrt (((x - CX) ** 2) + ((y - CY) ** 2)) > CR then
endGame := true
exit
end if
end loop
if endGame then
cls
put "YOU LOSE"
end if
|
or i've attached it
Description: |
Try to keep in the black circle. |
|
 Download |
Filename: |
Shaking Window GAME.t |
Filesize: |
2.47 KB |
Downloaded: |
195 Time(s) |
|
|
|
|
|
 |
[Gandalf]

|
Posted: Wed Jun 08, 2005 3:14 pm Post subject: (No subject) |
|
|
Welcome!
Great idea for a simple game! Nice first post.
Keep in mind though that you should always be limiting your use of proccess' to almost nothing.
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
decon1985

|
Posted: Wed Jun 08, 2005 3:52 pm Post subject: WHOA! |
|
|
I may just be a novice, and this might not mean much coming from me, but this is fantastic! I think this would work very well in a battle game when you take damage or you do damange, either way. Great program man!
|
|
|
|
|
 |
fehrge
|
Posted: Wed Jun 08, 2005 4:06 pm Post subject: (No subject) |
|
|
I also think that it is a really cool idea. Nice program.
|
|
|
|
|
 |
Delos

|
Posted: Wed Jun 08, 2005 6:52 pm Post subject: (No subject) |
|
|
Nice! Try to add a counter that displays how long the player lasted. You'll need to incorporate Time.Elapsed() for that.
|
|
|
|
|
 |
Drake
|
Posted: Wed Jun 08, 2005 9:49 pm Post subject: (No subject) |
|
|
Great idea to begin with. Making a game with it was awesome, too!
And the best part is that, at first, you wouldn't think it has much use. But if you sit down and think about it, it is very useful.
Bits to both of you!
|
|
|
|
|
 |
ViRuAl_InFeCtiON_vErsIonX

|
Posted: Sat Sep 03, 2005 12:45 am Post subject: (No subject) |
|
|
[mod:51fb78cadd="Cervantes"]
If you're going to ressurect an old topic, at least do it with something useful, not a "open a million windows" program.
[/mod:51fb78cadd]
|
|
|
|
|
 |
|
|