Follow TV Tropes

Following

Pacific makes a game in 24 hours

Go To

Tzetze DUMB from a converted church in Venice, Italy Since: Jan, 2001
DUMB
#26: Nov 27th 2010 at 10:20:08 AM

Oh wow I didn't know that you were going to actually be putting code, cool.

I'm pretty surprised that you took my suggestion to do a programming game, but hey, this looks like it could turn out cool.

If I may make a suggestion - just give the bullet type fields vx and vy (velocity x, velocity y) and use that to update the location each step - that way you could skip the dir if/else, and make it a bit easier to make bullets go in arbitrary directions (omnidirectional? wink) later.

It's best to make a constructor for all types (types are "structs" in C and every other language ever, I'm told. If not, I'm sure Tzetze will correct me.).

Heh. It's one of those concepts that have a lot of names, since it's pretty simple.

edited 27th Nov '10 10:20:27 AM by Tzetze

[1] This facsimile operated in part by synAC.
Ponicalica from facing Buttercup Since: May, 2010
#27: Nov 27th 2010 at 10:21:20 AM

Given the name omnisource, the omnisources should probably create things.

the future we had hoped for
Wicked223 from Death Star in the forest Since: Apr, 2009
#28: Nov 27th 2010 at 10:25:42 AM

So wait, the omnisources are going the be the targets, and the bullets are the things being programmed by the player?

You can't even write racist abuse in excrement on somebody's car without the politically correct brigade jumping down your throat!
Pacific Oh Yeah? from da beach house Since: Jan, 2001
Oh Yeah?
#29: Nov 27th 2010 at 10:34:27 AM

Oh wow I didn't know that you were going to actually be putting code, cool.

Not sure there's really another way to do a liveblog of making a game. I was thinking of posting the game so far at the end of each day (since I'm doing 12 hours/sleep/12 hours) and posting it after every step would be tiresome.

If I hit a bug, I don't list it in the liveblog, unless it happens to be a particularly tenacious one. (I've made a couple mistakes so far, but they were pretty easy to deal with..)

Given the name omnisource, the omnisources should probably create things.

I was wondering about that. Enemies, perhaps? It would have to be not random, because randomness in a game of this type could be a little disasterous.

So wait, the omnisources are going the be the targets, and the bullets are the things being programmed by the player?

At the moment. I want the player to be able to put down more objects than just bullets before they set it going, and right now I'm trying to think what else would be interesting.

I'm trying at the moment to create some sort of chain going from the bullet, which creates an explosion, which creates fire, which turns into smoke, I'll post that next when it makes sense.

GoggleFox rrrrrrrrr from Acadia, yo. Since: Jul, 2009
rrrrrrrrr
#30: Nov 27th 2010 at 10:47:17 AM

Interesting idea you have here. I couldn't hope to make a playable game in that short a time, at this point (mostly because of my personal requirements for game programming) but I'd like to see what you end up with.

Sakamoto demands an explanation for this shit.
Pacific Oh Yeah? from da beach house Since: Jan, 2001
Oh Yeah?
#31: Nov 27th 2010 at 11:34:15 AM

Updated the way fire works. Now it damages the omnisources (1 damage for 30 loops, 3 fires, should do 90 damage in total, so it makes bullets more effective)

I also made bullets have a "damage" field, which damages the omnisource on contact (before, it was the explosion that did all the damage). If a bullet passes through fire, it increases the ammount of damage it does. I added this merely so fire would do something to bullets. It doesn't do anything to explosions yet.

When fire reaches the top of the screen, it becomes smoke, which goes down the screen. I don't know what smoke is going to do.

Type fire
 Field x,y
 Field life
 Field dir
 Field smoke
End Type

Function newfire(x,y,dir,smoke)
f.fire=New fire
fx=x
fy=y
flife=30
fdir=dir
fsmoke=smoke
End Function

Function updatefire()
For f.fire=Each fire
 Local f_speed=-5
 If fsmoke=1 Then f_speed=5
 flife=flife-1
 If flife=20
  If fdir=1
   newfire(fx+5,fy+f_speed,0,fsmoke)
  Else
   newfire(fx-5,fy+f_speed,1,fsmoke)
  End If
 End If
 If fy<0 Then fsmoke=1
 If fsmoke=0
  For o.omnisource=Each omnisource
   If Rects Overlap(fx,fy,10,10,ox,oy,80,80)
    ohp=ohp-1
   End If
  Next
  For b.bullet=Each bullet
   If Rects Overlap(fx,fy,10,10,bx,by,23,23)
    bdamage=bdamage+1
   End If
  Next
 End If
 If flife<0 Then Delete f
Next
End Function

Smoke is drawn grey.

For f.fire=Each fire
 Color 255,126,0
 If fsmoke=1 Then Color 30,30,30
 Rect fx,fy,10,10
Next

Here's the bullet, all I added was one field, so I didn't think this was worth posting, but I'll put it here anyway.

Type bullet
 Field x,y
 Field dir
 Field damage
End Type

Function newbullet(x,y)
b.bullet=New bullet
b\x=x
b\y=y
b\damage=0
End Function

Function updatebullets()
Local freebullet=0
For b.bullet=Each bullet
 freebullet=0
 If b\dir=0
  b\x=b\x-2
 Else
  b\x=b\x+2
 End If
 If b\x<0 Then b\dir=1
 If b\x>1028 Then b\dir=0
 For o.omnisource=Each omnisource
  If Rects Overlap(b\x,b\y,23,23,o\x,o\y,80,80)
   o\hp=o\hp-b\damage
   newexplosion(b\x+12,b\y+12)
   freebullet=1
  End If
 Next
 If freebullet=1 Then Delete b
Next
End Function

edited 27th Nov '10 11:44:56 AM by Pacific

Pacific Oh Yeah? from da beach house Since: Jan, 2001
Oh Yeah?
#32: Nov 27th 2010 at 12:03:08 PM

Something I've just realised, the TV Tropes markup has removed all the backslashes.

Backslashes appear when referring to a type field (bullet's x (b\\x) comes out as bx, for example.)

edited 27th Nov '10 12:13:45 PM by Pacific

Tzetze DUMB from a converted church in Venice, Italy Since: Jan, 2001
DUMB
#33: Nov 27th 2010 at 12:06:38 PM

You can escape backslashes with backslashes; e.g., \\\\ renders as \\.

[1] This facsimile operated in part by synAC.
Pacific Oh Yeah? from da beach house Since: Jan, 2001
Oh Yeah?
#34: Nov 27th 2010 at 12:11:12 PM

Wouldn't that also start a new line?

Wicked223 from Death Star in the forest Since: Apr, 2009
#35: Nov 27th 2010 at 12:12:10 PM

\\

Use null tags.

You can't even write racist abuse in excrement on somebody's car without the politically correct brigade jumping down your throat!
Pacific Oh Yeah? from da beach house Since: Jan, 2001
Oh Yeah?
#36: Nov 27th 2010 at 1:00:47 PM

[up] Done

Let's add some innocent civilians.

Type civilian
 Field x,y
End Type

Function newcivilian(x,y)
c.civilian=New civilian
cx=x
cy=y
End Function

draw():

For c.civilian=Each civilian
 Color 0,255,0
 Rect cx,cy,30,30
Next

These guys are green.

In the setup, I assign them to the right mouse button, because I'm not making a menu yet.

 Case 0
  Color 255,255,255
  Rect msx,msy,10,10
  If Mouse Hit(1) Then newbullet(msx-12,msy-12)
  If Mouse Hit(2) Then newcivilian(msx-15,msy-15)
  If Key Hit(28) Then setup=1

Wonder what they should do? maybe walk around in a pattern, and die horribly if they get hit? Thier hit needs to start off a chain reaction of some sort. Right now, remember there are bullets, explosions, and fire to use on any object.

edited 27th Nov '10 1:02:07 PM by Pacific

Ponicalica from facing Buttercup Since: May, 2010
#37: Nov 27th 2010 at 1:54:59 PM

Maybe give them a health field and have a civilian with low health start panicking.

the future we had hoped for
Pacific Oh Yeah? from da beach house Since: Jan, 2001
Oh Yeah?
#38: Nov 27th 2010 at 2:13:02 PM

[up] Good idea. Maybe thier speed could increase as they get more panicked.

I've given the civilians some sort of pattern. At first I was trying to get them to move in a rhombus, but they kept moving upwards slowly. I thought it might work, so I barriered the sides of the screen, and made thier speed invert. It sucks, but it'll do for now, I don't have time to waste improving it. (It made some pretty interesting patterns earlier, so I'll have to see.)

Function newcivilian(x,y)
c.civilian=New civilian
cx=x
cy=y
cxspeed=2
cyspeed=2
End Function

Function updatecivilian()
For c.civilian=Each civilian
 cx=cx+cxspeed
 ctick=ctick+1
 If ctick>30 Then cy=cy-cyspeed
 If ctick>60 Then cx=cx-cxspeed*3
 If ctick>90 Then cy=cy+cyspeed*2
 If ctick>120 Then ctick=0

everywhere it says "speed" used to be a contant 2 or a four, (the fours so it overrode the statement before moving it in the other direction) I added speed to get it to change direction. I made it go triple speed x-ways in order to force it to collide with the sides of the screen.

 If cy<0
  cy=0
  cyspeed=-2
 End If
 If cy>768
  cy=768
  cyspeed=2
 End If
 If cx<0
  cx=0
  cxspeed=-2
 End If
 If cx>1024
  cx=1024
  cxspeed=2
 End If
Next
End Function

And there's the barriers. As I said, improving thier cycle is a waste of time right now. It's sort of a... Semi-diamond right now. I want to try and cause them to react to some elements, more importantly at the moment.

edited 27th Nov '10 2:13:39 PM by Pacific

Tzetze DUMB from a converted church in Venice, Italy Since: Jan, 2001
DUMB
#39: Nov 27th 2010 at 2:14:21 PM

Wouldn't that also start a new line?

Only at the end of a line. It's pretty weird.

[1] This facsimile operated in part by synAC.
Pacific Oh Yeah? from da beach house Since: Jan, 2001
Oh Yeah?
#40: Nov 27th 2010 at 2:32:33 PM

Here's the whole thing so far as a .zip. 24.exe runs it.

There's the whole code on Pastebin.

Thought it might be worth posting it just so people can feel how it runs so far.

edited 27th Nov '10 2:33:00 PM by Pacific

Psyga315 Since: Jan, 2001
#41: Nov 27th 2010 at 2:38:20 PM

It's good, but fairly short, either because you know where to place the bullets, thus destroying the Omnisourse, or that you have to reset because there weren't enough bullets to take down the Omnisourse, and you can't place more.

Pacific Oh Yeah? from da beach house Since: Jan, 2001
Oh Yeah?
#42: Nov 28th 2010 at 9:39:14 AM

It's good, but fairly short, either because you know where to place the bullets, thus destroying the Omnisourse, or that you have to reset because there weren't enough bullets to take down the Omnisourse, and you can't place more.

Yeah, it's completely straightforward how to destroy the omnisource at the moment. There'll need to be less direct ways to destroy it, maybe the bullet would be an expensive placement, considering how powerful it is?

I've done 12 hours so far, and I've got another 12 to do today. I was otherwise engaged for most of today, so I'll bleed this over into tommorrow if I can. It doesn't give me that much of an advantage, really.

So... five hours today... Seven tommorrow? Perhaps.

Bleh, first change I'm doing is to make it so when two bullets collide, they create an explosion. Mostly because if a bullet misses any other target, it'll just be idly bounding around the same walls for eternity. This loop is within the b.bullet loop in updatebullets(), So they're referred to as bb.bullet, since they can't use the same local variable to loop through them, otherwise it'll get stuck in the loop forever.

 For bb.bullet=Each bullet
  If Rects Overlap(b\x,b\y,23,23,bb\x,bb\y,23,23)
   newexplosion(b\x+12,b\y+12)
   freebullet=1
   Delete bb
  End If
 Next

It returns the error that b doesn't exist. I take out each line in turn to see where the problem is. It runs fine when "Delete bb" is taken out, and this happens.

 For bb.bullet=Each bullet
  If bb<>b
<—— this line fixes it. It makes sure it only explodes on contact with a bullet that is not itself.
   If Rects Overlap(b\x,b\y,23,23,bb\x,bb\y,23,23)
    newexplosion(b\x+12,b\y+12)
    freebullet=1
    Delete bb
   End If
  End If
 Next

Trying Ponicalica's suggestion of making civilians panic when low on health. They now have a "hp" field, which is set to 400 in newcivilian(), and this is added to updatebullets:

 For c.civilian=Each civilian
  If Rects Overlap(b\x,b\y,23,23,c\x,c\y,30,30)
   c\hp=c\hp-b\damage
   newexplosion(b\x+12,b\y+12)
   freebullet=1
  End If
 Next

(copy pasted from the omnisource's damage script, except with "c" instead of o for consistency, and the civilian's rectangle calculated at the same size)

This is put in the explosion's code, copy pasted again:

For c.civilian=Each civilian
 If Rects Overlap(e\x-(e\size/2),e\y-(e\size/2),e\size,e\size,c\x,c\y,30,30)
  c\hp=c\hp-1
 End If
Next

And this to updatefire(), also copypasted. Just to get civilians to be damaged in the same way as the omnicore. Bad practice copying this much stuff, I know, but it might be useful if their behaviour ends up radically different by the end.

  For c.civilian=Each civilian
   If Rects Overlap(f\x,f\y,10,10,c\x,c\y,30,30)
    c\hp=c\hp-1
   End If
  Next

If a civilian runs out of hp, they delete.

Function updatecivilian()
For c.civilian=Each civilian
 c\x=c\x+c\xspeed
 c\tick=c\tick+1
 If c\tick>30 Then c\y=c\y-c\yspeed
 If c\tick>60 Then c\x=c\x-c\xspeed*3
 If c\tick>90 Then c\y=c\y+c\yspeed*2
 If c\tick>120 Then c\tick=0
 If c\y<0
  c\yspeed=-2
 End If
 If c\y>768
  c\yspeed=2
 End If
 If c\x<0
  c\xspeed=-2
 End If
 If c\x>1024
  c\xspeed=2
 End If
 If c\hp<0 Then Delete c
Next
End Function

In draw, I draw thier amount of health on thier bodies.

For c.civilian=Each civilian
 Color 0,255,0
 Rect c\x,c\y,30,30
 Color 0,0,0
 Text c\x+1,c\y+5,c\hp
Next

This works, but the civilians don't die, they are good at dodging out of the way of explosions.

I'll try and get them to move more erratically next.

Pacific Oh Yeah? from da beach house Since: Jan, 2001
Oh Yeah?
#43: Nov 28th 2010 at 11:27:29 AM

This seems to work, although it's not ideal, and the original pattern is lost.

Function updatecivilian()
For c.civilian=Each civilian
 cx=cx+cxspeed
 ctick=ctick+1
 If ctick>(chp/20)+10 Then cy=cy-cyspeed
 If ctick>((chp/20)*2)+20 Then cx=cx-cxspeed*3
 If ctick>((chp/20)*3)+30 Then cy=cy+cyspeed*2
 If ctick>((chp/20)*4)+40 Then ctick=0
(the rest of the code that you've already seen)
Next
End Function

Before, each time the tick reached the point the civilian changed direction, it would be at 30 ticks, 60 ticks, 90 ticks, 120 ticks. now, with this version, when they get lower on health, they change direction a lot faster depending on thier health.

It took me a while to figure out the best way to make the time gradually decrease. I came up with this from trying to generate the same number as before when chp was 1, then generating lower numbers the lower their health got. They still move in the same shape as it gets lower, but the shape just gets smaller.

This results in the civilians moving around in a lot less predictable patterns once bullets are thrown into the fray. This will be a good thing if the field is full of dangerous stuff at any point.

edited 28th Nov '10 11:33:22 AM by Pacific

Pacific Oh Yeah? from da beach house Since: Jan, 2001
Oh Yeah?
#44: Nov 28th 2010 at 12:40:30 PM

Thought of what the ninja can do. It can fall slowly down the screen, firing laser shuriken (bullets for the time being) until it hits the bottom. Where it explodes.

Function updateninja()
For n.ninja=Each ninja
n\y=n\y+1
If n\y>768-30
 newexplosion(n\x-15,n\y-15)
 Delete n
End If
Next
End Function

this is called last. I also amended its area in draw, because I refered to it as b instead of n. I keep doing that.

now to add shooting. I give it a "tick" field so it has a timer. It shoots one bullet left, then right.

Function updateninja()
For n.ninja=Each ninja
n\y=n\y+1
n\tick=n\tick+1
If n\tick=100 Then newbullet(n\x-(30+23),n\y)
If n\tick=200
 newbullet(n\x+(30+23),n\y,1)
 n\tick=0
End If
If n\y>768-30
 newexplosion(n\x-15,n\y-15)
 Delete n
End If
Next
End Function

I added a new optional parameter on the end of newbullet(), that allows its direction to be set upon creation. This hasn't affected the other bullets. Only the ninja creates right-facing bullets at the moment.

Function newbullet(x,y,dir=0)
b.bullet=New bullet
b\x=x
b\y=y
b\damage=0
b\dir=dir
End Function

I assign it to the space bar for the moment.

  If Mouse Hit(1) Then newbullet(msx-12,msy-12)
  If Mouse Hit(2) Then newcivilian(msx-15,msy-15)
  If Key Hit(57) Then newninja(msx-15,msy-15)

The presence of a ninja causes total choas. But not enough chaos!

Pacific Oh Yeah? from da beach house Since: Jan, 2001
Oh Yeah?
#45: Nov 28th 2010 at 12:53:20 PM

This is added to updateninja(). The ninja is now on fire.

If ntick=50 Or ntick=150 Then newfire(nx+15,ny-10,1,0)

It leaves a trail of fire as it falls. Truly it is a deadly foe. What can make up for this overadvantage?

in updateexplosions:

For n.ninja=Each ninja
 If Rects Overlap(ex-(esize/2),ey-(esize/2),esize,esize,nx,ny,30,30)
  newexplosion(nx-15,ny-15)
  Delete n
 End If
Next

in updatefire:

  For n.ninja=Each ninja
   If Rects Overlap(fx,fy,10,10,nx,ny,30,30)
    newexplosion(nx-15,ny-15)
    Delete n
   End If
  Next

in updatebullets:

 For n.ninja=Each ninja
  If Rects Overlap(bx,by,23,23,nx,ny,30,30)
   newexplosion(nx-15,ny-15)
   Delete n
  End If
 Next

EDIT: Ah, it should be (nx+15,ny+15), otherwise the explosion comes out at too much of an offset. I have fixed this. Also, freebullet=1 is now called when a bullet collides with a ninja, it wasn't deleting on impact, giving the bullet an advantage.

edited 28th Nov '10 2:27:42 PM by Pacific

Pacific Oh Yeah? from da beach house Since: Jan, 2001
Oh Yeah?
#46: Nov 28th 2010 at 2:41:27 PM

Type bear
 Field x,y
 Field speed
 Field tick
End Type

Function newbear(x,y)
a.bear=New bear
a\x=x
a\y=y
a\speed=-2
End Function

Function updatebear()
For b.bear=Each bear
 b\x=b\x+b\speed
 b\tick=b\tick+1
 If b\x<0 Then b\speed=2
 If b\x>1028 Then b\speed=-2
 If b\tick=30 Then newninja(b\x-(b\speed*3),b\y+30)
 If b\tick=60 Then newninja(b\x-(b\speed*3),b\y+28)
 If b\tick=90 Then newninja(b\x-(b\speed*3),b\y)
 If b\tick>150 Then b\tick=0
Next
End Function

Taking Tzetze's advice and making the bear have a speed variable instead of a dir variable. This also makes it useful for projecting ninjas in front of it. It drops three ninjas in a pattern before cooling down for a second. Why three? Because it shoots one out of each eye, obviously.

It's rendered behind everything except the omnisource, and updates after everything.

For a.bear=Each bear
 Color 64,0,64
 Rect a\x,a\y,80,80
Next

It's big and purple.

I haven't posted any chaos from the field in a while, so now is a good time

Psyga315 Since: Jan, 2001
#47: Nov 28th 2010 at 2:47:50 PM

Hm... Perhaps you should make a read me and tell someone who hasn't seen this tread or has no idea what the shapes are a bit about the game to try and help them out a little.

Wicked223 from Death Star in the forest Since: Apr, 2009
#48: Nov 28th 2010 at 2:55:09 PM

I'll take care of that.

You can't even write racist abuse in excrement on somebody's car without the politically correct brigade jumping down your throat!
Wicked223 from Death Star in the forest Since: Apr, 2009
#49: Nov 28th 2010 at 3:41:20 PM

A recap, then:

Untitled Game

Untitled Game is a Programming Game based around objects (or, object) called the Omnisource. The player's job is to destroy these omnisources by placing other objects on the field (implemented), which will cost money (not implemented).

Objects added so far (updates to the ubjects will be in sub-bullets:

  1. Omnisource - Currently just sits at a designated spot for killing. Has 5000 hp thus far.
  2. Bullet - Bullets are simple projectiles that, when placed, travel left until they hit the omnisource.
    • Now have their own seperate damage field, as opposed to the explosion doing all the damage.
    • When two bullets collide, an explosion is created. This is mainly to keep the bullets from bouncing from side to side for all eternity.
  3. Explosions - What gets created when the bullet touches the omnisource. Every time it touches the omnisource, 1 point of HP gets taken off.
  4. Ninja - Does nothing at first implementation.
    • Can now fall slowly down the screen, firing laser shuriken (currently bullets) until it hits the bottom. Where it explodes.
    • They're now on fire. That's right. Flaming ninjas. Who knew?
  5. Fire - Exactly What It Says on the Tin. When an explosion deletes itself, a new fire is created.
    • The creation method was changed when it turned out to look more like a snake than fire. It now slowly crawls to the top of the screen, looking like an image toggling backward and forward.
    • Omnisource damage capability added in second update, can also increase the effectiveness of bullets if they pass through the fire.
  6. Civilian - An innocent bystander. Has no stated function at first implementation.
    • Initially moved in a rhombus shape, but they kept slowly moving upward, so the sides of the screen were barriered, and made their speeds invert on contact.
    • Were given a health field and made to panic when their health is running low. When they run out of HP, they delete themselves.
    • Their changes in direction are made to move faster when their health is low.
  7. Bear - A big purple thing that shoots three ninjas before cooling down, shooting one out of each eye.

You can't even write racist abuse in excrement on somebody's car without the politically correct brigade jumping down your throat!
Pacific Oh Yeah? from da beach house Since: Jan, 2001
Oh Yeah?
#50: Nov 28th 2010 at 3:52:07 PM

Wow, thanks Wicked!

I've done six hours and I'm out. I'll go to bed and finish this tommorrow. There isn't too long to go now.


Total posts: 55
Top