Thrive Game Development
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Thrive Game Development

Development of the evolution game Thrive.
 
HomeHome  PortalPortal  Latest imagesLatest images  SearchSearch  RegisterRegister  Log inLog in  
Welcome new and returning members!
If you're new, read around a bit before you post: the odds are we've already covered your suggestion.
If you want to join the development team, sign up and tell us why.
ADMIN is pleased to note that this marquee has finally been updated.
ADMIN reminds you that the Devblog is REQUIRED reading.
Currently: The Microbe Stage GUI is under heavy development
Log in
Username:
Password:
Log in automatically: 
:: I forgot my password
Quick Links
Website
/r/thrive
GitHub
FAQs
Wiki
New Posts
Search
 
 

Display results as :
 
Rechercher Advanced Search
Statistics
We have 1675 registered users
The newest registered user is dejo123

Our users have posted a total of 30851 messages in 1411 subjects
Who is online?
In total there are 13 users online :: 0 Registered, 0 Hidden and 13 Guests

None

Most users ever online was 443 on Sun Mar 17, 2013 5:41 pm
Latest topics
» THIS FORUM IS NOW OBSOLETE
Cell Swarming Emptyby NickTheNick Sat Sep 26, 2015 10:26 pm

» To all the people who come here looking for thrive.
Cell Swarming Emptyby NickTheNick Sat Sep 26, 2015 10:22 pm

» Build Error Code::Blocks / CMake
Cell Swarming Emptyby crovea Tue Jul 28, 2015 5:28 pm

» Hello! I can translate in japanese
Cell Swarming Emptyby tjwhale Thu Jul 02, 2015 7:23 pm

» On Leave (Offline thread)
Cell Swarming Emptyby NickTheNick Wed Jul 01, 2015 12:20 am

» Devblog #14: A Brave New Forum
Cell Swarming Emptyby NickTheNick Mon Jun 29, 2015 4:49 am

» Application for Programmer
Cell Swarming Emptyby crovea Fri Jun 26, 2015 11:14 am

» Re-Reapplication
Cell Swarming Emptyby The Creator Thu Jun 25, 2015 10:57 pm

» Application (programming)
Cell Swarming Emptyby crovea Tue Jun 23, 2015 8:00 am

» Achieving Sapience
Cell Swarming Emptyby MitochondriaBox Sun Jun 21, 2015 7:03 pm

» Microbe Stage GDD
Cell Swarming Emptyby tjwhale Sat Jun 20, 2015 3:44 pm

» Application for Programmer/ Theorist
Cell Swarming Emptyby tjwhale Wed Jun 17, 2015 9:56 am

» Application for a 3D Modeler.
Cell Swarming Emptyby Kaiju4u Wed Jun 10, 2015 11:16 am

» Presentation
Cell Swarming Emptyby Othithu Tue Jun 02, 2015 10:38 am

» Application of Sorts
Cell Swarming Emptyby crovea Sun May 31, 2015 5:06 pm

» want to contribute
Cell Swarming Emptyby Renzope Sun May 31, 2015 12:58 pm

» Music List Thread (Post New Themes Here)
Cell Swarming Emptyby Oliveriver Thu May 28, 2015 1:06 pm

» Application: English-Spanish translator
Cell Swarming Emptyby Renzope Tue May 26, 2015 1:53 pm

» Want to be promoter or project manager
Cell Swarming Emptyby TheBudderBros Sun May 24, 2015 9:00 pm

» A new round of Forum Revamps!
Cell Swarming Emptyby Oliveriver Wed May 20, 2015 11:32 am


 

 Cell Swarming

Go down 
2 posters
AuthorMessage
tjwhale
Theorist
tjwhale


Posts : 87
Reputation : 26
Join date : 2014-09-07

Cell Swarming Empty
PostSubject: Cell Swarming   Cell Swarming EmptyWed Apr 08, 2015 8:31 am

Taking this video as inspiration here is some very naive swarming mechanics.



Swarming is quite an important part of the game because it's the mechanism by which you get to the next stage so it has to be good.

Watching it made me think a lot about how fast the game is going to be, right now it's very leisurely but that ecoli video is bonkers. (It may well be sped up).

Finding the right speed is going to be difficult.

Also it would be nice if there were organisms which wanted to be close together but sat mostly still (though maybe that's just them going very slowly in this fashion).



Code:


import pygame
import math
import random
from pygame.locals import *

#setup

background_colour = (255,255,255)
(width, height) = (600, 300)

screen = pygame.display.set_mode((width, height))#,pygame.FULLSCREEN)
screen.fill(background_colour)
pygame.display.set_caption('Swarming')
pygame.font.init()

myfont = pygame.font.SysFont("monospace", 20)

def distance(i,j):
   return math.sqrt((i.x - j.x)**2 + (i.y - j.y)**2)

class animal:
   def __init__(self):
      self.x = random.randint(-100,100)
      self.y = random.randint(-100,100)
      self.dx = 1
      self.dy = 1
      self.angle = random.uniform(0,2*math.pi)


   def display(self):
      pygame.draw.circle(screen, (255,0,0), [int(self.x + width/2), int(self.y + height/2)], 5)
      endx = self.x - 15*math.cos(self.angle)
      endy = self.y - 15*math.sin(self.angle)
      pygame.draw.line(screen, (0,0,255), [int(self.x + width/2), int(self.y + height/2)],
         [int(endx + width/2), int(endy + height/2)], 3)


   def think(self, mousepos):
      bros = []
      for i in animals:
         bros.append([i,distance(self,i)])
      bros.sort(key = lambda bros: bros[1])
      if bros[1][1] <= 20:
         self.dx += 0.1*(self.x - bros[1][0].x)
         self.dy += 0.1*(self.y - bros[1][0].y)
      if math.sqrt((self.x - mousepos[0])**2 + (self.y - mousepos[1])**2) <= 50:
         self.dx += 0.1*(self.x - mousepos[0])
         self.dy += 0.1*(self.y - mousepos[1])
      for i in bros:
         if i[1] <= 100:
            self.dx += -0.0002*(self.x - i[0].x)
            self.dy += -0.0002*(self.y - i[0].y)
      if abs(self.dx) >= 5:
         self.dx = self.dx*0.9
      if abs(self.dy) >= 5:
         self.dy = self.dy*0.9            

   def update(self):
      timestep = 0.3
      self.x += self.dx*timestep
      self.y += self.dy*timestep
      if self.x >= width/2:
         self.x += -width
      if self.x <= -width/2:
         self.x += width
      if self.y >= height/2:
         self.y += -height
      if self.y <= -height/2:
         self.y += height
      self.angle = math.atan2(self.dy, self.dx)


animals = []
for i in range(50):
   animals.append(animal())

running = True
while running:
   for event in pygame.event.get():
       if event.type == pygame.QUIT:
           running = False
       elif event.type == KEYDOWN:
           if event.key == K_ESCAPE:
               running = False

   screen.fill(background_colour)

   mousepos = [pygame.mouse.get_pos()[0] - width/2, pygame.mouse.get_pos()[1] - height/2]

   for i in animals:
      i.display()
      i.think(mousepos)
      i.update()


   pygame.display.flip()

pygame.quit()

Back to top Go down
StealthStyle L
Newcomer
StealthStyle L


Posts : 72
Reputation : 7
Join date : 2014-06-05
Age : 27
Location : Behind you!!!

Cell Swarming Empty
PostSubject: Re: Cell Swarming   Cell Swarming EmptyWed Apr 08, 2015 9:47 am

Huh. That's not how I pictured swarming. Interesting video.

The first one should definitely not be used for gameplay. It's far too fast for gameplay, even if it is realistic. Although I guess that's obvious. (And by the way, I don't think it's sped up, as the seconds in the top left must be there for some purpose. This is unless they were trying to fool viewers.)

I would even go so far as to say the second is a bit quick too. Plus, I would assume that the numbers would have to be less than this or the computer might explode, especially if there are multiple swarms. Also, can you even zoom out enough to get this view. It would be closer up and so the microbes would flit across the screen even more.
Back to top Go down
tjwhale
Theorist
tjwhale


Posts : 87
Reputation : 26
Join date : 2014-09-07

Cell Swarming Empty
PostSubject: Re: Cell Swarming   Cell Swarming EmptyWed Apr 08, 2015 10:25 am

I hadn't noticed the timestamp, I guess it looks fast because it's micrometers.

If the gameplay is to be unrealistically slow then how slow? How should it feel?

At first I thought a swarm of that speed was madness but then I thought about bison stampedes in old west films.



Maybe there could be microbes whose strategy is to trample anyone in their path.
Back to top Go down
StealthStyle L
Newcomer
StealthStyle L


Posts : 72
Reputation : 7
Join date : 2014-06-05
Age : 27
Location : Behind you!!!

Cell Swarming Empty
PostSubject: Re: Cell Swarming   Cell Swarming EmptyWed Apr 08, 2015 10:45 am

I don't think those buffalo in that bullalo video move as fast as those microbes. I think that speed would be accecptable. It's not unmanageably fast, but it's not slow either. It can't be too fast to be uncomfortable to view. I think your version is just a bit too fast.

I'm not sure that microbes trampling microbes would be an effective method. They could, however, surround the microbe preventing an escape...which would probably require a complex signal agent.

Edit: Sorry, I misread something. I think the buffalos are a fine speed.
Back to top Go down
Sponsored content





Cell Swarming Empty
PostSubject: Re: Cell Swarming   Cell Swarming Empty

Back to top Go down
 
Cell Swarming
Back to top 
Page 1 of 1
 Similar topics
-
» Cell Membrane
» Microbial Compounds and Organelles
» Microbe Stage Progress Report
» Video of "Sim Cell"
» Miscellaneous Bugs And Questions That Don't Deserve Their Own Thread Thread

Permissions in this forum:You cannot reply to topics in this forum
Thrive Game Development :: Development :: Design :: Prototypes-
Jump to: