int main(void) { // instantiate window GWindow window = newGWindow(320, 240); // instantiate slider addToRegion(window, newGLabel("0"), "SOUTH"); GSlider slider = newGSlider(0, 100, 50); setActionCommand(slider, "slide"); addToRegion(window, slider, "SOUTH"); addToRegion(window, newGLabel("100"), "SOUTH"); // listen for events while (true) { // wait for event GActionEvent event = waitForEvent(ACTION_EVENT); // if window was closed if (getEventType(event) == WINDOW_CLOSED) { break; } // if action command is "slide" if (strcmp(getActionCommand(event), "slide") == 0) { printf("slider was slid to %i\n", getValue(slider)); } } // that's all folks closeGWindow(window); return 0; }
o/** * slider.c * * David J. Malan * [email protected] * * Demonstrates a slider. */ // standard libraries #include <stdio.h> #include <string.h> // Stanford Portable Library #include <spl/gevents.h> #include <spl/ginteractors.h> #include <spl/gwindow.h> int main(void) { // instantiate window GWindow window = newGWindow(320, 240); // instantiate slider addToRegion(window, newGLabel("0"), "SOUTH"); GSlider slider = newGSlider(0, 100, 50); setActionCommand(slider, "slide"); addToRegion(window, slider, "SOUTH"); addToRegion(window, newGLabel("100"), "SOUTH"); // listen for events while (true) { // wait for event GActionEvent event = waitForEvent(ACTION_EVENT); // if window was closed if (getEventType(event) == WINDOW_CLOSED) { break; } // if action command is "slide" if (strcmp(getActionCommand(event), "slide") == 0) { printf("slider was slid to %i\n", getValue(slider)); } } // that's all folks closeGWindow(window); return 0; }
/** * Instantiates, configures, and returns label for scoreboard. */ GLabel initScoreboard(GWindow window) { GLabel label = newGLabel("0"); setFont(label, "SansSerif-18"); setLocation(label, getWidth(window) / 2, getHeight(window) / 2 - 30); return label; }
int main(void) { // instantiate window GWindow window = newGWindow(320, 240); // instantiate label GLabel label = newGLabel(""); setFont(label, "SansSerif-36"); add(window, label); // count down from 50 to 0 for (int i = 50; i >= 0; i--) { // to store 50 through 0 (with '\0'), we need <= 3 chars char s[3]; // convert i from int to string sprintf(s, "%i", i); // update label setLabel(label, s); // center label double x = (getWidth(window) - getWidth(label)) / 2; double y = (getHeight(window) - getHeight(label)) / 2; setLocation(label, x, y); // linger for 100 milliseconds pause(100); } // that's all folks closeGWindow(window); return 0; }
/** * Instantiates, configures, and returns label for scoreboard. */ GLabel initScoreboard(GWindow window) { GLabel scoreboard = newGLabel(""); setFont(scoreboard, "SansSerif-30"); setColor(scoreboard, "RED"); return scoreboard; }
/** * Instantiates, configures, and returns label for scoreboard. */ GLabel initScoreboard(GWindow window) { GLabel Scoreboard = newGLabel(""); add (window, Scoreboard); setLocation(Scoreboard, 300, 200); return Scoreboard; }
/** * Instantiates, configures, and returns label for scoreboard. */ GLabel initScoreboard(GWindow window) { GLabel label = newGLabel(""); setFont(label, "SansSerif-36"); add(window, label); return label; }
/** * Instantiates, configures, and returns label for scoreboard. */ GLabel initScoreboard(GWindow window) { GLabel scoreboard = newGLabel("%i", points); setFont(scoreboard, "SansSerif-18"); add(window, scoreboard); return NULL; }
/** * Instantiates, configures, and returns label for scoreboard. */ GLabel initScoreboard(GWindow window) { GLabel scoreboard = newGLabel("0"); setFont(scoreboard, "SansSerif-48"); setColor(scoreboard, "0xC0C0C0"); add(window, scoreboard); return scoreboard; }
/** * Instantiates, configures, and returns label for scoreboard. */ GLabel initScoreboard(GWindow window) { GLabel label = newGLabel(""); setFont(label, "SansSerif-24"); setLocation(label, 8, HEIGHT - 10); add(window, label); return label; }
/** * Instantiates, configures, and returns label for scoreboard. */ GLabel initScoreboard(GWindow window) { GLabel label = newGLabel(""); setFont(label, "SansSerif-72"); setColor(label, "GRAY"); add(window, label); sendToBack(label); return label; }
/** * Instantiates, configures, and returns label for scoreboard. */ GLabel initScoreboard(GWindow window) { // TODO GLabel label = newGLabel("0"); setFont(label, "SansSerif-36"); add(window, label); setLocation(label, (getWidth(window) - getWidth(label)) / 2, (getHeight(window) - getHeight(label)) / 2); return label; }
/** * Instantiates, configures, and returns label for scoreboard. */ GLabel initScoreboard(GWindow window) { GLabel label = newGLabel(" "); setFont(label, "SansSerif-50"); setColor(label, "C0C0C0"); add(window, label); setLocation(label, 185, 300); return label; }
/** * Instantiates, configures, and returns label for scoreboard. */ GLabel initScoreboard(GWindow window) { // Initializing Score Board GLabel scoreboard = newGLabel(""); setFont(scoreboard, "Ubuntu-50"); add(window, scoreboard); return scoreboard; }
/** * Instantiates, configures, and returns label for scoreboard. */ GLabel initScoreboard(GWindow window) { // instantiate label GLabel label = newGLabel(""); setFont(label, "SansSerif-36"); setLocation(label, 200, 300); add(window, label); return label; }
/** * Instantiates, configures, and returns label for scoreboard. */ GLabel initScoreboard(GWindow window) { GLabel label = newGLabel("Score: 0"); setColor(label, "BLACK"); setLocation(label, WIDTH / 2 - getWidth(label) / 2, HEIGHT * .33); add(window, label); return label; }
/** * Instantiates, configures, and returns label for scoreboard. */ GLabel initScoreboard(GWindow window) { GLabel score = newGLabel("0"); setFont(score, "SansSerif-36"); add(window, score); double x_score = (getWidth(window) - getWidth(score)) / 2; double y_score = (getHeight(window) - getHeight(score)) / 2; setLocation(score, x_score, y_score); return score; }
/** * Instantiates, configures, and returns label for scoreboard. */ GLabel initScoreboard(GWindow window) { GLabel label = newGLabel("0"); setColor(label, "BLACK"); setFont(label, "SansSerif-20"); updateScoreboard(window, label, 0); add(window, label); return label; }
/** * Instantiates, configures, and returns label for scoreboard. */ GLabel initScoreboard(GWindow window) { GLabel label = newGLabel (""); setFont(label,"Courier-25"); setColor(label,"DF7401"); setFilled(label, true); add(window,label); setLocation(label,150,150); return label; }
GLabel initEnd(GWindow window) { GLabel label = newGLabel("Click to Close Window"); setFont(label, "SansSerif-24"); add(window, label); double x = (getWidth(window) - getWidth(label)) / 2; double y = (getHeight(window) - getHeight(label)) / 2; setLocation(label, x, y); return label; }
/** * Instantiates, configures, and returns label for scoreboard. */ GLabel initScoreboard(GWindow window) { // TODO GLabel label = newGLabel(""); setFont(label, "SansSerif-36"); add(window, label); // count down from 50 to 0 return label; }
/** * Instantiates, configures, and returns label for scoreboard. */ GLabel initScoreboard(GWindow window) { // TODO int points; GLabel label = newGLabel(" "); setFont(label, "ComicSans-18"); add(window, label); setLocation(label, 192, 332); return label; }
/** * Instantiates, configures, and returns label for scoreboard. */ GLabel initScoreboard(GWindow window) { GLabel label = newGLabel("0"); setFont(label, "SansSerif-24"); double x = (getWidth(window) - getWidth(label)) / 2; double y = (getHeight(window) + getFontAscent(label)) / 2; setLocation(label, x, y); add(window, label); return label; }
GLabel initlives(GWindow window) { GLabel label = newGLabel(""); setFont(label, "SansSerif-24"); add(window, label); double x = 10; double y = 590; setLocation(label, x, y); return label; }
GLabel initWin(GWindow window) { GLabel label = newGLabel("You Win!!!"); setFont(label, "SansSerif-24"); add(window, label); double x = (getWidth(window) - getWidth(label)) / 2; double y = (getHeight(window) - getHeight(label)) / 2; setLocation(label, x, y); return label; }
/** * Instantiates, configures, and returns label for scoreboard. */ GLabel initScoreboard(GWindow window) { // TODO GLabel label = newGLabel(""); setFont(label, "SansSerif-72"); setColor(label, "GRAY"); add(window, label); setLabel(label, "0"); setLocation(label, 175, 200); return label; }
/** * Instantiates, configures, and returns label for scoreboard. */ GLabel initScoreboard(GWindow window) { GLabel label = newGLabel("0"); setFont(label,"DejaVuSansMono-40"); double x = (getWidth(window) - getWidth(label)) / 2; double y = (getHeight(window) - getHeight(label)) / 2; setLocation(label, x, y); setColor(label, "GRAY"); add(window, label); return label; }
/** * Instantiates, configures, and returns label for scoreboard. */ GLabel initScoreboard(GWindow window) { int posX = (WIDTH / 2) - 19; int posY = (HEIGHT / 2) - 19; GLabel label = newGLabel("0"); setFont(label, "Ubuntu-bold-30"); setColor(label, "LIGHT_GRAY"); setLocation(label, posX, posY); add(window, label); return label; }
/** * Instantiates, configures, and returns label for scoreboard. */ GLabel initScoreboard(GWindow window) { GLabel label = newGLabel("CLICK"); double x = (WIDTH - getWidth(label)) / 2; double y = (HEIGHT + getFontAscent(label)) / 2; setFont(label, "Courier 10 Pitch-bold-50"); setColor(label, "#cccccc"); setLocation(label, x, y); sendToBack(label); return label; }
/** * Instantiates, configures, and returns label for scoreboard. */ GLabel initScoreboard(GWindow window) { // TODO GLabel scoreboard = newGLabel("0"); setFont(scoreboard, "SansSerif-22"); double x = (getWidth(window) - getWidth(scoreboard)) / 2; double y = (getHeight(window) - getHeight(scoreboard)) / 2; setLocation(scoreboard, x, y); setColor(scoreboard, "#7700AA"); add(window, scoreboard); return scoreboard; }