I programming in Chipmunk Basic with arrow keys, and random coordinate gen.

In summary, the person is having trouble using the arrow keys and spacebar in a game they are trying to create using Chipmunk Basic. They have experience programming in other Basic Softwares but cannot figure out how to incorporate graphics and sprites with colors in CB. They are looking for help in making their game work and have posted a link to a forum for further assistance.
  • #1
CharlieO1212
10
0
I am trying to make a game in Chipmunk Basic using the arrow keys but I can't because I cannot figure out how. I have programmed in other Basic Softwares but I cannot figure out how to use the arrow keys and spacebar in my programs. An example (much simplified) of a game I am making is snake (if you don't know what it is its where a line goes around the screen and you need to come into contact with colored dots to make your "snake" bigger. If you run into yourself then the game ends). IF you know how to make graphics/sprites with colors in CB (Chipmunk Basic) then please let me know because CB is a lot different with graphics than other programs.
 
Technology news on Phys.org
  • #2


Can you make this work?

while
s=inkey$
if s<>"" then print asc(s)
wend

Test that by gently pressing a single key, like X or 3.
If that works then gently press one arrow key and post the results.
For X it should print a single number.
For an arrow key it may print 1 or 2 or 3 or 4 lines of single numbers.

If that works then you need to build a little machine in software that uses the numbers.
 
  • #3


It gave me a type mismatch error in line 20
 
  • #5


It sounds like you are having trouble incorporating the arrow keys and spacebar into your game in Chipmunk Basic. One solution could be to use the INKEY$ function to read the input from the arrow keys and spacebar. This function will return a string representing the last key pressed, which you can then use in your game logic. Another option could be to use the KEY statement to assign specific actions to certain keys. For example, you could assign the left arrow key to turn the snake left and the right arrow key to turn the snake right. As for creating graphics and sprites in Chipmunk Basic, you may need to use the DRAW statement to create lines and shapes, and the COLOR statement to set the color for those shapes. I recommend consulting the Chipmunk Basic documentation or reaching out to their support team for further assistance. Good luck with your game!
 

1. What is Chipmunk Basic?

Chipmunk Basic is a programming language and interpreter that was originally developed for the Apple Macintosh in the 1980s. It is a simple, easy-to-learn language that allows users to write and run programs on their computer.

2. How do I use arrow keys in Chipmunk Basic?

To use arrow keys in Chipmunk Basic, you can use the INKEY$ function to detect when a key is pressed. Then, you can use conditional statements to determine which arrow key was pressed and perform the desired action.

3. Can I use Chipmunk Basic for game development?

Yes, Chipmunk Basic can be used for game development. It has built-in graphics and sound capabilities, as well as the ability to handle user input. However, it may not be as robust as other programming languages specifically designed for game development.

4. How do I generate random coordinates in Chipmunk Basic?

To generate random coordinates in Chipmunk Basic, you can use the RND function, which returns a random number between 0 and 1. You can then use this number to calculate the coordinates within a specific range or use it as an index to select coordinates from a list.

5. Can I compile my Chipmunk Basic program into an executable file?

No, Chipmunk Basic is an interpreted language, meaning that the program is executed line by line rather than being compiled into a standalone executable file. However, there are third-party tools that can wrap Chipmunk Basic programs into standalone applications for specific platforms.

Similar threads

  • Programming and Computer Science
Replies
24
Views
1K
Replies
7
Views
4K
  • Programming and Computer Science
Replies
4
Views
954
  • Programming and Computer Science
Replies
32
Views
2K
  • Programming and Computer Science
Replies
5
Views
3K
Replies
2
Views
882
  • Programming and Computer Science
Replies
20
Views
3K
  • Programming and Computer Science
Replies
2
Views
2K
Replies
10
Views
960
  • STEM Academic Advising
Replies
5
Views
935
Back
Top