Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / Hello everyone, I made pong.

Author
Message
Thomas John Gorham
5
Years of Service
User Offline
Joined: 23rd Jun 2018
Location:
Posted: 23rd Jun 2018 16:50 Edited at: 24th Jun 2018 00:04
Hi guys my name is Thomas and I'm new to AppGameKit.

I just made what I think is a working version of Pong. If anyone would like to look at the code and suggest ways for me to improve that would be most helpful. I've not done any programming before besides the original darkbasic when I was 14! It's my new hobby and I'm really enjoying the challenge.

I'm sure everything i've done is probably the worst way to do it, I look forward to any criticisms and learning opportunities.

Thanks for having me And thanks for making a great trial version of AppGameKit free to use
My next thing will be to try and make a space invaders style game.


Attachments

Login to view attachments
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 24th Jun 2018 17:25
Welcome,
I did not test the game but I see, you managed to use GoSub and it still looks clean, although in general its a better idea to use functions instead.
And instead of checking ballpath every time, you could change the direction of the ball directly: ballposx=ballposx+balldirx

Nevertheless I think you did a good job.
Thomas John Gorham
5
Years of Service
User Offline
Joined: 23rd Jun 2018
Location:
Posted: 24th Jun 2018 17:45
Thanks.

What's the advantage of a function over gosub? Is this really dumb question?
Carharttguy
7
Years of Service
User Offline
Joined: 8th Jul 2016
Location: Belgium
Posted: 25th Jun 2018 11:38
Hi Thomas

That's not a dumb question at all. The main difference is that a function can return a value (or not). And with a function, you ALWAYs return to the calling line and proceed from there. (So as a label with a return statement)
GoSub is something from the past, rarely used these days and makes it easy to program very hard to read code (spaghetti code) as you can jump from here to there and back again.

A funciton is way cleaner, generally, there is no good reason to choose GoSub over a Function. (Well, there are, if you have only a very limited callstack/memory available, but if that's the case AppGameKit Tier 1 would be a very bad choice)

I hope you can understand my English and it helps you understanding the difference.
Ask away if you have more questions.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 25th Jun 2018 13:47
A function reduces repetitive code and is more modular.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Thomas John Gorham
5
Years of Service
User Offline
Joined: 23rd Jun 2018
Location:
Posted: 2nd Jul 2018 12:01
Hey guys thanks for the tips to swapping to functions instead of gosub.

I have started writing a new project, a level of a space invaders style game. I started using functions and would love it if you could have a squiz at my thread and help.

Login to post a reply

Server time is: 2024-04-23 21:38:43
Your offset time is: 2024-04-23 21:38:43