Coding the Game

View previous topic View next topic Go down

Coding the Game

Post by Miles on Sun Jan 15, 2017 4:04 pm

Since I wanted to check, if the Sprites fitted into scratch and would move how I wanted them to, I already coded this part to be sure, that everything would work out. And programming this took me almost 4 hours, since I had quite a challenge to get the code right, although I looked at an tutorial.

Here are a few of the problems that I encountered while writing the code.

Firstly the (probably) most funny problem, that I had - the character was walking on the ceiling, when you wanted to walk to the left side. I dont even know how this happened but it happened. Here you can see a screenshot I took.


Oh well. First I tried to change the directon the cat was facing at, but it did not change, that it was walking on the surface. Therefore I had to take the risk and to write a seperate part in the script for walking. I firstly hesitated, since I am not a lover of risk-taking, but I did it - and it worked out! I was so happy, to see the cat walking normally after that!
Here you can see the code the tutorial "how to make a character move" suggested me, that did not work out:


And here you can see my changed version, to get the cat from the ceiling down to the floor:

I just seperated the command to two seperate commands, communicating with the sprites for each side.

But with that I already had to face my next two problems, that I weren't able to solve yet - they're quite a nut to crack. One of them was, that the second walking sprite did not wait 0.3 seconds to be switched in. It just ignores this part of the script and I dont know, how to slow down this one exchange.
The other one is, that when you are jumping to the left side, the sprite will keep on flicking to the right-hand side. I dont know what I need to change, but I will try to make two jump commands to fix this.

Furthermore I learned already from the tutorial, so that I was able to create a variable for life and for loosing a life without any help! I am pretty proud about that, even if it was not a bit thing to do after I used the tutorial to do the first part of the walking-script. This shows, that I am a pretty fast learner when working with Sources and using what I researched to create something else with my new knowledge.


The last challenge I encountered while doing the movement of the sprites was, inserting the soundtracks. This had actually nothing to do with the sprite itself, but I wanted to test out, if it is possible to insert music into the game. Thanks to my research I already knew how to do this - but I made a small mistake, that kept the music from starting.
I troubleshooted the whole thing and fixed it. But I have to be aware of, that already little mistakes can keep a whole string of code from working.
My mistake was to take this pink block....


....instead of this one:


Also I had some problem with using the hide-block, but it did not take me as long.
avatar
Miles
Admin

Posts : 35
Join date : 2016-10-06

View user profile http://process-journal.forumotion.co.uk

Back to top Go down

Re: Coding the Game

Post by Miles on Tue Jan 17, 2017 10:13 am

Yesterday was also a hard day for coding somehow. I encountered again some problems and were no able to solve the ones from the session before. So I decided to meet with our coding teacher tomorrow after school to ask for some ideas how I can solve my problems.

But before I start, you have to know, that the screen in scratch has the dimensions 480x360 _always_. Means, a long Map like mine, has to be broken down into smaller pieces, which then need to be connected, so that it looks like it is one long map. And connecting them and getting them to move with the playable character has it little sandtraps.

Firstly, I had the problem, that the Map was beginning in the middle of the screen, instead of on the side of it. I tried of course to move it to the left by telling it "go to -180x and 0y", but it did not move at first. I tried again and again and then, somehow, it worked out. It is a miracle for me, why the command just decided to work from a moment to the other. It would be really interesting to know the magic behind this. I can also not move it further than -180, because the Maps disappears then (??). There is still a white big line, between the Map and the edge, that I try to get away.

Another problem that I encountered, while installing the maps, was, that some of the maps just show up part of themselves on the side of the screen. You can't move them away either, which is really frustrating. Another problem, that gets added to my bug list.

avatar
Miles
Admin

Posts : 35
Join date : 2016-10-06

View user profile http://process-journal.forumotion.co.uk

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum