Main Page   Data Structures   File List   Globals  

mouse_input.c File Reference

Works out which line of text the user clicked. More...

#include "white_interface.h"

Go to the source code of this file.

Functions

void poin_entry_Init ()
 VCC Init function. More...

void poin_entry_Run ()
 VCC Run function. More...


Detailed Description

Works out which line of text the user clicked.

This block is a cut down version of the process_input part of the input module. It looks at where the user clicked and determines which line of text they selected on the lobby screen. Using this information, start_game.c can work out which player they chose as their opponent.

Definition in file mouse_input.c.


Function Documentation

void poin_entry_Init  
 

VCC Init function.

This function runs when the VCC simulation is first started.

Definition at line 19 of file mouse_input.c.

00020 {
00021 }

void poin_entry_Run  
 

VCC Run function.

This runs whenever a message arrives at the mouse_in port.

Definition at line 29 of file mouse_input.c.

00030 {
00031   int y, grid_line, screen_line;
00032   mouse_drag input;
00033 
00034   /* When a mouse_drag message arrives, extract the y
00035      coordinate of where the user clicked. */
00036   if (mouse_in_Enabled())
00037   {
00038     input = *mouse_in_Value();
00039     y = input.down_y;
00040 
00041     /* The lobby screen is a 10 line display, with
00042        each line 24 pixels high. The bottom line
00043        starts at the 80th pixel up the screen. */
00044 
00045     /* get the number of pixels up the 10 line display
00046        that the user clicked on. */
00047     y = y - 80;
00048 
00049     /* now work out how many lines up the display
00050        they clicked. */
00051     grid_line = y / 24;
00052 
00053     /* convert this to the number of lines down
00054        the display they clicked, excluding a
00055        title line and spacing line at the top. */       
00056     screen_line = grid_line - 8;        
00057     screen_line = -screen_line;
00058 
00059     /* as long as the user clicked on a valid
00060        area of the screen, output the line
00061        number to the start_game block. */
00062     if (screen_line > 0)
00063     {
00064       line_out_Post(screen_line);
00065     }
00066   }
00067 }


Copyright © 2002 Andrew Bates
Last Updated 04/04/02