Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Spaceship
#3
Your at a fork in the road where you can go either way. One way leads to spaghetti code. While the other organizes. However the organization uses classes. I would highly recommend learning them if you have not yet. Of course in one's learning experience, you have to go down the route of spaghetti code to understand why its so unorganized to begin with. It depends on your age, and knowledge of coding, and how far you actually want to take it. None of which i know the answer to. So take it with a grain of salt.

a few opinions:
  • There should only ever be one line in your entire game of pygame.display.update() . If you have more than one, you are heading in the direction of spaghetti code.
  • A Spaceship class and Bullet class would better organize this code and put sporadic lines with its corresponding class. Thus it is easier to start with the main game loop and spawn out objects from there.

The closest example i can think of is this example of the code a the bottom comparing the two programs of with classes and without. Also my tutorial series does a space invaders simple clone to illustrate proper coding techniques. In this particular part, i convert the code of the player into the Player class. In part 4, i make the player have a method of shooting (bullets).
SheeppOSU likes this post
Recommended Tutorials:
Reply


Messages In This Thread
Spaceship - by abscorpy - May-06-2021, 07:05 PM
RE: Spaceship - by BashBedlam - May-06-2021, 10:16 PM
RE: Spaceship - by abscorpy - May-11-2021, 09:08 PM
RE: Spaceship - by metulburr - May-08-2021, 11:37 PM
RE: Spaceship - by BashBedlam - May-12-2021, 02:26 PM
RE: Spaceship - by Windspar - May-15-2021, 01:49 PM
RE: Spaceship - by abscorpy - May-22-2021, 11:25 AM
RE: Spaceship - by SheeppOSU - May-24-2021, 09:56 PM
RE: Spaceship - by BashBedlam - Jun-01-2021, 02:24 PM
RE: Spaceship - by abscorpy - Jul-23-2021, 09:25 AM
RE: Spaceship - by metulburr - Jul-23-2021, 07:00 PM
RE: Spaceship - by abscorpy - Jul-26-2021, 07:15 AM
RE: Spaceship - by SheeppOSU - Aug-06-2021, 07:53 PM
RE: Spaceship - by abscorpy - Aug-07-2021, 11:25 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020