News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_EgoTrip

Programming in CPCTelera

Started by EgoTrip, 21:22, 26 September 15

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

EgoTrip

Now I got the environment working, I need to make something in it. I have a basic understanding of C but I'm far from an expert or even competent really. I want to use this topic to start a game from scratch, and other people can learn from it too. I've tried to follow that video tutorial but its in Spanish and I cant understand it.

What I want to do is a top-down game in Mode 1, where you move from screen to screen, similar to Zelda movement (fancy scrolling isn't necessary to learn yet, I want to learn the basics first).

So where do I start, I guess getting a sprite moving around the screen would be a good place. What exactly do I do? So far all I've figured out is how to set the mode (Mode 1) and change the border to pink.

Zoe Robinson


Please bear in mind that I've not tried CPCTelera but I'm reasonable in a few programming languages, so this is a general programming thing.

For movement I'd recommend a creating a simple array to keep track of the player's position on the screen, something like: pos (x,y)

Then add controls that move up, down, left and right on the screen, with associated functions:

up() {
pos (x,y) -= pos (0,1);
}

down() {
pos (x,y) += pos (0,1);
}

left() {
pos (x,y) -= pos (1,0);
}

right() {
right() {
pos (x,y) += pos (1,0);
}

Bear in mind that the code I just wrote there is more PHP than C but the principle should be reasonably similar. Essentially, each call is modifying one variable in the position array by 1 unit, so when you call the "move up" function, it changes the "y" part of the array to set the position 1 row further up the screen; and the opposite is true for the "move down" function.

You'd then need to redraw the screen so the sprite is in the new position, of course.

ronaldo

@EgoTrip: I recommend you to use the examples included with CPCtelera to learn step by step how to do things. The code is fully commented to show you how things work. Have a look and play around with them, making modifications and testing your ideas.

It's better to learn how individual things work while making small demos before starting a complete game. Then, when you grasp all the basic things (sprite drawing, keyboard reading, game loop, screen updating...), try simple game ideas like a basic pong, arkanoid or something alike.

After completing a first simple game with all the parts, you will be ready to create some other games, progressively increasing technical difficulty.

To increase your skills is always better go step by step, one at a time. Is not only about learning, but learning well and then master ;)

Powered by SMFPacks Menu Editor Mod