Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming of Mobile and Handheld Devices Lecture 7: Programming OXO for Palm OS Rob Pooley

Similar presentations


Presentation on theme: "Programming of Mobile and Handheld Devices Lecture 7: Programming OXO for Palm OS Rob Pooley"— Presentation transcript:

1 Programming of Mobile and Handheld Devices Lecture 7: Programming OXO for Palm OS Rob Pooley rjp@macs.hw.ac.uk

2 Designing and programming a new application This lecture describes the design and implementation of the second game we set out in lecture 4. This time we are building a noughts and crosses (tic-tac-toe) game. Here is the statechart that we defined previously.

3 The design and implement process The design of a Palm OS application from a statechart follows the steps below: 1.Each state defines a distinct point in the evolution of the application and needs a screen (Form) which corresponds to it; 2.Each form needs an event handler function; 3.For each successor state, each form needs one mechanism which triggers a move to that state; 4.Update the AppHandleEvent function to deal with the Form types and their handlers defined above; 5.Work out what information needs to exist across states; 6.Set up the project and its makefile.

4 Initial state – black filled circle Welcome to noughts and crosses. Would you like to play a game? PlayExit

5 X to move state – buttons only Click on a square to plant a cross Done

6 Or draw a bitmap over invisible buttons

7 Buttons set to not usable are invisible

8 X has moved state Your X move was valid/invalid OK Show an alert?

9 Notes as we go The state to date must be remembered across states for checking and display updating. The text should be different depending on the validity of the move made. –That is not a user determined outcome, but is triggered by an internal check. –The grid is displayed with a cross if the move was valid, maybe with some indication of where the invalid move appeared otherwise?

10 Winning state Alerts are for grabbing attention and giving information. Do we need separate forms or alerts for each outcome? We can use a Field and set its text if we want to. Congratulations to X/O You won! Done

11 Control Resources Different resources are associated with different controls, as follows: Button Button Resource (tBTN) Popup trigger Popup Trigger Resource (tPUT) Selector trigger Selector Trigger Resource (tSLT) Repeat controlRepeating Button Resource (tREP) Push buttonPush Button Resource (tPBN) Check boxCheck Box Resource (tCBX) SliderSlider Resource (tsld) Feedback sliderFeedback Slider Resource (tslf)

12 FldInsert Function Replace the current selection if any with the specified string and redraw the field. Declared In Field.h Prototype Boolean FldInsert(FieldType *fldP,const Char *insertChars, UInt16 insertLen) Parameters fldP Pointer to the field object (FieldType structure) into which to insert.FieldType insertChars Text string to be inserted. insertLen Length in bytes of the text string to be inserted, not counting the trailing null character. Returns Returns true if string was successfully inserted. Returns false if:

13 Setting up the files for a build

14 Edit the makefile to reflect this ## -------------------------------------------------------------------- # Sources and Resources # List all the sources (.c/.cpp) and resources (.xrd) in your project # Use project relative path names with forward slashes (src/code.cpp). # Please do not use spaces in directory names. # A note about XRD resource files: If you have existing.rsrc or.rcp, # files refer to the documentation for the GenerateXRD tool to convert # them into XRD files for use with all Palm OS SDKs. ## -------------------------------------------------------------------- # TODO: Update all sources and resources SOURCES = src/AppMain.c RESOURCES = rsc/OXO.xrd SLIB_DEF_FILE =


Download ppt "Programming of Mobile and Handheld Devices Lecture 7: Programming OXO for Palm OS Rob Pooley"

Similar presentations


Ads by Google