Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 22 in printed book and digital formats -- plus a one-year subscription (beginning with 23.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 23.3

COLUMN

Xojo Tennis Part 2

Playing tennis with Xojo and MBS

Issue: 23.3 (May/June 2025)
Author: Stefanie Juchmes-Simonis
Author Bio: Stefanie studied computer science at the University of Bonn. She came into contact with Xojo due to the work of her brother-in-law and got a junior developer position in early 2019 at Monkeybread Software.
Article Description: No description available.
Article Length (in bytes): 16,385
Starting Page Number: 70
Article Number: 23307
Resource File(s):

Download Icon project23307.zip Updated: 2025-04-30 22:34:20

Related Link(s): None

Excerpt of article text...

In the first part of this series, we set up the scene for our tennis game. Now let's bring some movement into the game. The elements that move in our game are the ball on one hand and the two paddles of the players on the other. We will start with the players' paddles, which should move up and down. To simplify things initially, we will move these paddles using buttons, but in the next part, they will be controlled using Phidgets joysticks.

We want to perform certain movements in our scene when specific keys are pressed. For this, we will use the KeyUp events of our window. This event fires when a key that has been pressed is released. We can retrieve the character from this event as a string.

However, some keys, such as the arrow keys, return specific strings. To compare these, we need to request the ASCII code from the return value to make the comparison possible. To identify the keys we want to use to control player 1 and player 2, we can first add the following line to the event and then press the corresponding keys:

MessageBox Asc(Key).ToString

...End of Excerpt. Please purchase the magazine to read the full article.