粉丝3.9万获赞138.0万

i wanted to know if chat gpt could make a video game so i asked it to make flappy bird for me, but we're gonna have one rule i'm not going to write a single line of code any code that we use is going to be written by chat gpt i'm just going to copy paste it over this could go very wrong i wrote a brief description of all the components that go into flappy bird real quick it spit out a six step plan to make flappy bird in the unity game engine, so following the instructions for steps one and two we're going to set up an empty game project and add our art for the background and the bird which brings us the step three which is to write a script to give life to the bird so it can flap its wings while flying to the right but we're not gonna write the script chagi bt is we're just gonna copy paste the script over tada it works, but there's a problem the bird is flying off the screen so we're gonna ask chat gpt to fix that and write a some code to have a camera follow the bird as it moves to the right, but you may have noticed that the bird is flying off the background that was a mistake i made setting up the background in the first place so i'm gonna chalk that one up to human error my bad with a quick adjustment we now have a script working great at this point i realized we don't want the game to start right away when the game loads we have to wait for the player to click at least once to flap their wings before the bird starts moving otherwise you go barreling into the ground as soon as the game starts as per our main rule i had chat gpt write all of the code to delay movement until the player had flapped their wings for the first time and success the game now waits until the first click and then you can flap flap flap your heart away have you been wondering where the art we've been using came from since chat gpt is writing all of the code well, if you haven't guessed already the art is generated by ai as well, i fed rough blockout sketches into mid journey and had it fill in the details for the background environment, the bird and the pipe obst this brings us to step number four things are going to get really interesting in step four obstacle pipes are going to start appearing chat gpt has given us instructions to hook up the physics for the pipe, which will cause the bird to collide with the pipe, which is how the game is going to end but as i was reading the instructions chat gpt have provided this line caught my eye chat gpt was planning to create the opposite goes off to the right of the screen that seems fine, but then it proposed moving the pipes left at a constant speed i can see why it suggested that since the pipes do appear to move to the left when you're playing you see the bird and camera are already moving to the right so the pipes should actually remain stationary and allow the bird to fly up to them i pointed this out to chat gpt and chat gpt agreed you're right it said and it proceeded to correct itself i copy pasted the code back in and now it works great except wait wait what's going on the birds flipping around like a like like some kind of cuckoo bird this is the first curveball that i'm going to throw at chat gpt because this was not part of the original design specification we're going to ask it to rotate the bird based on whether the bird is moving up or down without any hesitation chad gpt said sure you want the bird to tilt up and down you got it and it gave me the code to do so, and now we've got this awesome little bird that tilts up and down based on the direction it's moving rather than spinning around like a pinwheel and that brings us on to step number five to implement game over and scoring conditions what i really like about this process is that while chat gpt is taking care of the code i get to focus my attention on design work i get the position text elements on the screen i decide the distance between the pipes or the exact tuning numbers for how hard the bird flaps its wings so now we have scoring working but if you'll notice the points are actually incrementing before i get to the pipe that seems wrong i actually want the score to increment when the player passes through the happen the pipes so we're gonna ask chat gpt to adjust the code to give us more control over the exact moment in time that the point is awarded to the player the player now gets points when they actually pass through the pipe at this point i realized that we're missing a ground for the game the ground and flappy bird is really helpful to provide that constant sense of forward movement other than the pipes the ground was not part of the original specification, but i said nope we're gonna need it i let chat gpt know that we're gonna be adding a ground to the game and it gave me step by step directions how to set up a never ending ground the bird would be able to crash into and now we have an infinitely long ground along the bottom of the screen reinforcing that set of ford movement and then move on to step six which is to have a game over screen come up when the player makes a collision with the pipe or with the ground our coding assistant chat gpt didn't hesitate to provide us with detailed instructions as well as all of the code to set up the game over screen once again i was able to focus on the design elements like deciding what font size and color to use the sizing of the buttons and then paste the code that chat gpt had provided me to make the whole thing work and now we have a proper game over screen but wait there's one problem after the game over screen pops up the player input is still being received which means the bird can jump up after it has fallen to the ground that's kind of ridiculous so i told chat gpt that when the game over screen pops up, we need to stop the camera and stop movement so that the player shouldn't be able to control the bird anymore, but here's another mistake chat gpt made there was a simple coating error and the game wouldn't run at all i just told chat gpt that the error existed to see what it would do polite is always it apologize for the error and provided the correction after following its instructions we now disable player input when the game over screen is reached now this is where we're gonna get to our second curveball we're gonna add a high score system let's see how well chat gpt adjust this brand new request after we had basically finished all six steps of the original plan i copy pasted all the code it had provided me, but watch what happens when i run the game with the new high square code enabled i scored two points on this flappy bird run, but my high score was only listed as zero chat gpt wrote all this complicated logic with a simple error i told chat gpt i thought the problem was with the ad score function and it replied your right it's almost like we're working together we now have a high score system that works on this round i got a high score of nine and the score is retained between rounds so could somebody with no coding knowledge use chat gpt to make a game probably not yet, but we're getting there i'm definitely going to repeat this exercise with more complicated game types on future ai models so i hope you'll join me for that in the meantime happy game making。


