This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
// room script file
#define BUFFERAREA_LENGTH 240 // relative width of room background buffer area (480 pixels)
function PauseMoving (int charid) {
// Stops the supplied character but keeps its last frame
// For seamlessly changing walking speed, for example
char prevview = character[charid].view+1;
char prevloop = character[charid].loop;
char prevframe = character[charid].frame;
int wasmoving = character[charid].walking;
StopMoving(charid);
if (wasmoving) SetCharacterFrame(charid, prevview, prevloop, prevframe);
// since we're using his current view, the lock will be released automatically once the character is moved again
}
function WaitHidden(int gameloops) {
int prevmode = GetCursorMode; // store the current cursor mode
SetCursorMode(MODE_WAIT); // change to wait cursor mode
SetMouseCursor(prevmode); // change appearance to look like previous cursor mode
Wait(gameloops);
SetDefaultCursor(); // revert wait cursor to the default sprite
SetCursormode(prevmode); // revert to previous cursor mode
}
function on_mouse_click(MouseButton button) {
if (IsGamePaused()) return; // if game is paused, quit function
if (button == LEFT) { // if left mouse click
if (GetCursorMode() == MODE_WALK) { // if mouse is in walk mode
if (GetViewportX() + mouse.x >= game.room_width - (system.viewport_width / 2)) { // if clicked on right end of room
PauseMoving(GetPlayerCharacter()); // see above
character[GetPlayerCharacter()].x = character[GetPlayerCharacter()].x - (game.room_width - BUFFERAREA_LENGTH); // put character at left end of room
WaitHidden(1); // see above; let screen update before running global on_mouse_click
}
else if (GetViewportX() + mouse.x <= (system.viewport_width / 2)) { // if clicked on left end of room
PauseMoving(GetPlayerCharacter()); // see above
character[GetPlayerCharacter()].x = character[GetPlayerCharacter()].x + (game.room_width - BUFFERAREA_LENGTH); // put character at right end of room
WaitHidden(1); // see above; let screen update before running global on_mouse_click
}
}
}
// global on_mouse_click will be called afterwards -> character starts walking
}
Quote from: hello123 on Sat 09/04/2005 04:24:47I can't seem to use DisplaySpeechAt when programming dialogs
Quote from: hello123 (via pm)sorry to bug you, strazer, but DisplaySpeechAt does not seem to be in the manual. I can only find DisplaySpeech
Quote
Is there a way to get the integer value of the GUI object at a point, i.e., mouse.x, mouse.y?
GUIControl *thecontrol = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
if (thecontrol != null) integervalue = thecontrol.ID;
QuoteIt was on the "to-do" list before, & I know the Object-Based scripting, obviously, took priority.
while (character[GetPlayerCharacter()].y < 150) {
character[GetPlayerCharacter()].y -= 1; // increase this number to speed it up
Wait(1);
}
Quote from: Pumaman on Thu 07/04/2005 19:52:25QuoteThank you very much for the character tint function. This relieves me of much cheating with the AmbientTint command. Does this mean that region tints will also get luminance settings in the near future?
The lack of luminance in the region tints is a bit of an oversight -- it happened because region tints were the first type to be implemented, and weren't done as thoroughly as the ambient and object tints which came later. This would be a worthwhile addition to a future version, I agree.
// main global script
struct struct_AnimatedInventoryItem {
int normalgraphic;
int view;
int loop;
int animationdelay;
int repeat;
int currentframe;
int currentdelay;
};
#define AGS_MAX_INV_ITEMS 300
struct_AnimatedInventoryItem AnimatedInventoryItem[AGS_MAX_INV_ITEMS];
function AnimateInventoryItem(int invitemid, int view, int loop, int delay, int repeat) {
if (AnimatedInventoryItem[invitemid-1].view == 0) // if inv item does NOT have a view set (isn't animating)
AnimatedInventoryItem[invitemid-1].normalgraphic = theinvitem.Graphic; // store inv item's current (normal) graphic
// store supplied settings for animation routines (see repeatedly_execute):
AnimatedInventoryItem[invitemid-1].view = view;
AnimatedInventoryItem[invitemid-1].loop = loop;
AnimatedInventoryItem[invitemid-1].animationdelay = delay;
AnimatedInventoryItem[invitemid-1].repeat = repeat;
// reset current status so animation starts from beginning when this function is called on already animating inventory items:
AnimatedInventoryItem[invitemid-1].currentframe = 0;
AnimatedInventoryItem[invitemid-1].currentdelay = 0;
}
function StopAnimatingInventoryItem(int invitemid, int keepcurrentframe) {
if (AnimatedInventoryItem[invitemid-1].view) { // if inv item has a view set (is animating)
AnimatedInventoryItem[invitemid-1].view = 0; // reset the view so inv item will not be animated anymore
if (keepcurrentframe == 0) SetInvItemPic(invitemid, AnimatedInventoryItem[invitemid-1].normalgraphic; // if current frame should not be kept, change inv item graphic back to normal
}
}
function repeatedly_execute() {
int invitemid = 0; // start with first inventory item (array index starts at 0)
while (invitemid < AGS_MAX_INV_ITEMS) { // loop for each inventory item
if (AnimatedInventoryItem[invitemid].view) { // if inv item has a view set (is animating)
if (AnimatedInventoryItem[invitemid].currentdelay) AnimatedInventoryItem[invitemid].currentdelay--; // if delay until next frame has NOT yet elapsed, decrease it
else { // if delay until next frame has elapsed
SetInvItemPic(invitemid+1, GetGameParameter(GP_FRAMEIMAGE, AnimatedInventoryItem[invitemid].view, AnimatedInventoryItem[invitemid].loop, AnimatedInventoryItem[invitemid].currentframe);
// change inv item's graphic to new frame
AnimatedInventoryItem[invitemid].currentdelay = AnimatedInventoryItem[invitemid].animationdelay + GetGameParameter(GP_FRAMESPEED, AnimatedInventoryItem[invitemid].view, AnimatedInventoryItem[invitemid].loop, AnimatedInventoryItem[invitemid].currentframe);
// set delay until next frame to animation delay + new frame's delay
AnimatedInventoryItem[invitemid].currentframe++; // set following frame to display next
if (AnimatedInventoryItem[invitemid].currentframe >= GetGameParameter(GP_NUMFRAMES, AnimatedInventoryItem[invitemid].view, AnimatedInventoryItem[invitemid].loop, 0)) { // if no more frames in view loop
if (AnimatedInventoryItem[invitemid].repeat == 0) StopAnimatingInventoryItem(inventory[invitemid+1], 0); // if animation was set to play once, stop animation (reverting to normal graphic)
else if (AnimatedInventoryItem[invitemid].repeat == 1) AnimatedInventoryItem[invitemid].currentframe = 0; // if animation was set to repeat, set first frame to display next
else if (AnimatedInventoryItem[invitemid].repeat == 2) StopAnimatingInventoryItem(inventory[invitemid+1], 1); // if animation was set to play once and to keep last frame, stop animation keeping current frame
}
}
}
invitemid++; // loop to next inventory item
}
}
// main script header
import function AnimateInventoryItem(int invitemid, int view, int loop, int delay, int repeat);
import function StopAnimatingInventoryItem(int invitemid, int keepcurrentframe);
By continuing to use this site you agree to the use of cookies. Please visit this page to see exactly how we use these.
Page created in 0.789 seconds with 15 queries.