• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 15:15
CEST 21:15
KST 04:15
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL19] Finals Recap: Standing Tall9HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0TL Team Map Contest #5: Presented by Monster Energy6
Community News
Flash Announces Hiatus From ASL56Weekly Cups (June 23-29): Reynor in world title form?13FEL Cracov 2025 (July 27) - $8000 live event19Esports World Cup 2025 - Final Player Roster16Weekly Cups (June 16-22): Clem strikes back1
StarCraft 2
General
Statistics for vetoed/disliked maps The SCII GOAT: A statistical Evaluation Weekly Cups (June 23-29): Reynor in world title form? PiG Sty Festival #5: Playoffs Preview + Groups Recap The GOAT ranking of GOAT rankings
Tourneys
FEL Cracov 2025 (July 27) - $8000 live event RSL: Revival, a new crowdfunded tournament series Korean Starcraft League Week 77 Master Swan Open (Global Bronze-Master 2) [GSL 2025] Code S: Season 2 - Semi Finals & Finals
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma Mutation # 477 Slow and Steady
Brood War
General
Flash Announces Hiatus From ASL Player “Jedi” cheat on CSL Replays question BW General Discussion BGH Auto Balance -> http://bghmmr.eu/
Tourneys
[Megathread] Daily Proleagues [BSL20] Grand Finals - Sunday 20:00 CET Small VOD Thread 2.0 [BSL20] GosuLeague RO16 - Tue & Wed 20:00+CET
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Path of Exile What do you want from future RTS games? Beyond All Reason
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
Russo-Ukrainian War Thread US Politics Mega-thread Trading/Investing Thread Things Aren’t Peaceful in Palestine The Games Industry And ATVI
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [\m/] Heavy Metal Thread
Sports
2024 - 2025 Football Thread Formula 1 Discussion NBA General Discussion TeamLiquid Health and Fitness Initiative For 2023 NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Blogs
Culture Clash in Video Games…
TrAiDoS
from making sc maps to makin…
Husyelt
Blog #2
tankgirl
StarCraft improvement
iopq
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 639 users

The Big Programming Thread - Page 802

Forum Index > General Forum
Post a Reply
Prev 1 800 801 802 803 804 1031 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
TanGeng
Profile Blog Joined January 2009
Sanya12364 Posts
November 23 2016 15:18 GMT
#16021
lol
Moderator我们是个踏实的赞助商模式俱乐部
Manit0u
Profile Blog Joined August 2004
Poland17243 Posts
November 23 2016 16:01 GMT
#16022
On November 24 2016 00:15 tofucake wrote:
[image loading]

some of our devs need to learn how to manage their queries :\


That seems really small compared to what I deal with on a daily basis... One page doing 1.6mil requests in 21 seconds, another one doing 3 requests in 39 seconds...
Time is precious. Waste it wisely.
emperorchampion
Profile Blog Joined December 2008
Canada9496 Posts
November 23 2016 16:13 GMT
#16023
On November 23 2016 16:16 Acrofales wrote:
Show nested quote +
On November 23 2016 13:23 WarSame wrote:
I'm making a dungeon game and my trolls around running around like they're on meth. I can't figure out how to calm them down. This is in pygame.

The heartbeat:
    def run_game(self):
# Heartbeat
while not (self.game_over or self.level.player.is_dead):
self.handle_events()
self.move_creatures()
self.draw_screen()
pygame.time.wait(100)
self.end_game()


where draw_screen is
    def draw_screen(self):
# Update game visuals
self.screen.fill((0, 0, 0))
self.draw_blocks()
pygame.display.flip()
self.clock.tick(60)


The problem is that I can make the trolls slow down by increasing the wait time between game cycles, but then the player moves too slowly. I'm looking for a fair way to slow down how frequently the trolls move. Any ideas?


I believe the solution is:
self.remove_meth()





If only that worked IRL :/
TRUEESPORTS || your days as a respected member of team liquid are over
Cyx.
Profile Joined November 2010
Canada806 Posts
November 23 2016 16:46 GMT
#16024
On November 23 2016 13:23 WarSame wrote:
I'm making a dungeon game and my trolls around running around like they're on meth. I can't figure out how to calm them down. This is in pygame.

The heartbeat:
    def run_game(self):
# Heartbeat
while not (self.game_over or self.level.player.is_dead):
self.handle_events()
self.move_creatures()
self.draw_screen()
pygame.time.wait(100)
self.end_game()


where draw_screen is
    def draw_screen(self):
# Update game visuals
self.screen.fill((0, 0, 0))
self.draw_blocks()
pygame.display.flip()
self.clock.tick(60)


The problem is that I can make the trolls slow down by increasing the wait time between game cycles, but then the player moves too slowly. I'm looking for a fair way to slow down how frequently the trolls move. Any ideas?

Maybe I'm misunderstanding this, but I think what you want to do is often done by measuring how much time has passed since the last frame, and passing that value into your `move_creatures()`. Then you can scale that by movement speeds to get movement amounts:

last_time = pygame.time.get_time()
while not game_over:
time = pygame.time.get_time()
dt = time - last_time
self.move_creatures(dt)
last_time = time

// ...

def move_creatures(dt):
for c in self.creatures:
c.position += c.velocity * dt;
Manit0u
Profile Blog Joined August 2004
Poland17243 Posts
November 23 2016 16:59 GMT
#16025
Have you tried tinkering with the frames? If I remember correctly you can speed up/slow down the game via the frames setting.
Time is precious. Waste it wisely.
tofucake
Profile Blog Joined October 2009
Hyrule19030 Posts
November 23 2016 17:50 GMT
#16026
On November 24 2016 01:01 Manit0u wrote:
Show nested quote +
On November 24 2016 00:15 tofucake wrote:
[image loading]

some of our devs need to learn how to manage their queries :\


That seems really small compared to what I deal with on a daily basis... One page doing 1.6mil requests in 21 seconds, another one doing 3 requests in 39 seconds...

Yeah but 7 million people doing it on the landing page after login :|
Liquipediaasante sana squash banana
Acrofales
Profile Joined August 2010
Spain17970 Posts
November 23 2016 19:17 GMT
#16027
On November 24 2016 02:50 tofucake wrote:
Show nested quote +
On November 24 2016 01:01 Manit0u wrote:
On November 24 2016 00:15 tofucake wrote:
[image loading]

some of our devs need to learn how to manage their queries :\


That seems really small compared to what I deal with on a daily basis... One page doing 1.6mil requests in 21 seconds, another one doing 3 requests in 39 seconds...

Yeah but 7 million people doing it on the landing page after login :|

I hardly ever visit the landing page. Does that solve your problem?
tofucake
Profile Blog Joined October 2009
Hyrule19030 Posts
November 23 2016 19:32 GMT
#16028
On November 24 2016 04:17 Acrofales wrote:
Show nested quote +
On November 24 2016 02:50 tofucake wrote:
On November 24 2016 01:01 Manit0u wrote:
On November 24 2016 00:15 tofucake wrote:
[image loading]

some of our devs need to learn how to manage their queries :\


That seems really small compared to what I deal with on a daily basis... One page doing 1.6mil requests in 21 seconds, another one doing 3 requests in 39 seconds...

Yeah but 7 million people doing it on the landing page after login :|

I hardly ever visit the landing page. Does that solve your problem?

On our website you have to login to see anything (it's a reimbursement program thing) so everyone always sees the landing page.
Liquipediaasante sana squash banana
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
November 23 2016 19:39 GMT
#16029
On November 24 2016 01:46 Cyx. wrote:
Show nested quote +
On November 23 2016 13:23 WarSame wrote:
I'm making a dungeon game and my trolls around running around like they're on meth. I can't figure out how to calm them down. This is in pygame.

The heartbeat:
    def run_game(self):
# Heartbeat
while not (self.game_over or self.level.player.is_dead):
self.handle_events()
self.move_creatures()
self.draw_screen()
pygame.time.wait(100)
self.end_game()


where draw_screen is
    def draw_screen(self):
# Update game visuals
self.screen.fill((0, 0, 0))
self.draw_blocks()
pygame.display.flip()
self.clock.tick(60)


The problem is that I can make the trolls slow down by increasing the wait time between game cycles, but then the player moves too slowly. I'm looking for a fair way to slow down how frequently the trolls move. Any ideas?

Maybe I'm misunderstanding this, but I think what you want to do is often done by measuring how much time has passed since the last frame, and passing that value into your `move_creatures()`. Then you can scale that by movement speeds to get movement amounts:

last_time = pygame.time.get_time()
while not game_over:
time = pygame.time.get_time()
dt = time - last_time
self.move_creatures(dt)
last_time = time

// ...

def move_creatures(dt):
for c in self.creatures:
c.position += c.velocity * dt;

The creatures all move discrete distances. They have a speed, such as 1 or 2, and move that many squares per turn. Otherwise, yeah, that would make sense.

On November 24 2016 01:59 Manit0u wrote:
Have you tried tinkering with the frames? If I remember correctly you can speed up/slow down the game via the frames setting.

Yup. The frame rate is set to a maximum of 60 FPS, and it runs at that on my computer. If I lower that, then they move slower, but the player also now can move multiple times per draw. So I'm looking for a way to slow only the trolls down, without effecting the rest of the game, if that's possible.

On November 23 2016 13:49 meatpudding wrote:
Show nested quote +
On November 23 2016 13:23 WarSame wrote:
I'm making a dungeon game and my trolls around running around like they're on meth. I can't figure out how to calm them down. This is in pygame.

The heartbeat:
    def run_game(self):
# Heartbeat
while not (self.game_over or self.level.player.is_dead):
self.handle_events()
self.move_creatures()
self.draw_screen()
pygame.time.wait(100)
self.end_game()


where draw_screen is
    def draw_screen(self):
# Update game visuals
self.screen.fill((0, 0, 0))
self.draw_blocks()
pygame.display.flip()
self.clock.tick(60)


The problem is that I can make the trolls slow down by increasing the wait time between game cycles, but then the player moves too slowly. I'm looking for a fair way to slow down how frequently the trolls move. Any ideas?


Lots of ways to do this. In move_creatures you could add a counter like this
counter += 1
if counter < threshold: return
# reset the counter
counter = 0
...
# actual code here

This seems like a possibility. I'll give it a shot. Thanks!
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2016-11-23 20:22:10
November 23 2016 20:21 GMT
#16030
On November 23 2016 23:17 Nesserev wrote:
SMALL RANT
I'm really frustrated with the 4th Edition of 'The C++ Programming Language' by Bjarne Stroustrup. I loved the Special Edition, but it seems like the magic was lost a bit in this edition, and there's one thing that really fcking triggers me...

Uniform initialization... AKA ugly squiggly braces from hell... they're fucking ugly as shit, and the book is full of it.

This might sound dumb and shit, but it really ruins an otherwise perfectly good book for me.
END OF RANT


I actually really like the way C++ uses initialization lists. Everyone I show is like, whoa, neat, and it's very clear what its purpose is IMO. Also getting more usage in C++17 too so it's basically here to stay. What's wrong with the book?
There is no one like you in the universe.
Manit0u
Profile Blog Joined August 2004
Poland17243 Posts
November 23 2016 20:49 GMT
#16031
On November 24 2016 05:21 Blisse wrote:
Show nested quote +
On November 23 2016 23:17 Nesserev wrote:
SMALL RANT
I'm really frustrated with the 4th Edition of 'The C++ Programming Language' by Bjarne Stroustrup. I loved the Special Edition, but it seems like the magic was lost a bit in this edition, and there's one thing that really fcking triggers me...

Uniform initialization... AKA ugly squiggly braces from hell... they're fucking ugly as shit, and the book is full of it.

This might sound dumb and shit, but it really ruins an otherwise perfectly good book for me.
END OF RANT


I actually really like the way C++ uses initialization lists. Everyone I show is like, whoa, neat, and it's very clear what its purpose is IMO. Also getting more usage in C++17 too so it's basically here to stay. What's wrong with the book?


I agree that uniform initialization actually makes C++ a lot more concise and the code easier to write and follow. I see nothing wrong with that.
Time is precious. Waste it wisely.
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
Last Edited: 2016-11-24 05:19:29
November 24 2016 05:17 GMT
#16032
--- Nuked ---
Manit0u
Profile Blog Joined August 2004
Poland17243 Posts
Last Edited: 2016-11-24 13:23:35
November 24 2016 13:23 GMT
#16033

public static function bool2int($variable) {
if ($variable === TRUE) {
$result = (int) $variable;
} else if ($variable === FALSE) {
$result = (int) $variable;
} else {
$result = null;
}
return $result;
}


Kill me...
Time is precious. Waste it wisely.
icystorage
Profile Blog Joined November 2008
Jollibee19343 Posts
November 24 2016 13:38 GMT
#16034

if ($variable === TRUE) {
$result = (int) $variable;
} else if ($variable === FALSE) {
$result = (int) $variable;


sweet baby jesus
LiquidDota StaffAre you ready for a Miracle-? We are! The International 2017 Champions!
BluzMan
Profile Blog Joined April 2006
Russian Federation4235 Posts
November 24 2016 21:49 GMT
#16035
On November 24 2016 14:17 Nesserev wrote:
Show nested quote +
On November 24 2016 05:21 Blisse wrote:
I actually really like the way C++ uses initialization lists. Everyone I show is like, whoa, neat, and it's very clear what its purpose is IMO. Also getting more usage in C++17 too so it's basically here to stay. What's wrong with the book?

There's nothing wrong with the book, and I don't mind when initializer lists are used for actual "lists" (e.g. vectors, strings, etc.). But I genuinely dislike the use of the first line over the second.
int i {0};
int i = 0;

And the book is full of lines like the first one... that's all. This just feels so unnecessary... it's the only C++11/14/17 feature that I can think of that I really dislike.


Curly brackets as a habit save you from the dreaded vexing parse.
You want 20 good men, but you need a bad pussy.
BluzMan
Profile Blog Joined April 2006
Russian Federation4235 Posts
November 24 2016 21:52 GMT
#16036
On November 24 2016 22:23 Manit0u wrote:

public static function bool2int($variable) {
if ($variable === TRUE) {
$result = (int) $variable;
} else if ($variable === FALSE) {
$result = (int) $variable;
} else {
$result = null;
}
return $result;
}


Kill me...

Why would anyone write PHP these days? Quick and dirty stuff can be done with Node, and "proper" PHP looks a lot like a worse version of Java.
You want 20 good men, but you need a bad pussy.
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
November 24 2016 21:59 GMT
#16037
On November 25 2016 06:52 BluzMan wrote:
Show nested quote +
On November 24 2016 22:23 Manit0u wrote:

public static function bool2int($variable) {
if ($variable === TRUE) {
$result = (int) $variable;
} else if ($variable === FALSE) {
$result = (int) $variable;
} else {
$result = null;
}
return $result;
}


Kill me...

Why would anyone write PHP these days? Quick and dirty stuff can be done with Node, and "proper" PHP looks a lot like a worse version of Java.


Because PHP has the biggest market share so if you're maintaining a system it was probably written in PHP.
I'll always be your shadow and veil your eyes from states of ain soph aur.
Manit0u
Profile Blog Joined August 2004
Poland17243 Posts
Last Edited: 2016-11-25 02:50:38
November 24 2016 22:12 GMT
#16038
On November 25 2016 06:52 BluzMan wrote:
Show nested quote +
On November 24 2016 22:23 Manit0u wrote:

public static function bool2int($variable) {
if ($variable === TRUE) {
$result = (int) $variable;
} else if ($variable === FALSE) {
$result = (int) $variable;
} else {
$result = null;
}
return $result;
}


Kill me...

Why would anyone write PHP these days? Quick and dirty stuff can be done with Node, and "proper" PHP looks a lot like a worse version of Java.


"Proper" PHP app can be developed much faster and much cheaper than its Java counterparts while still adhering to all the "enterprise" bullshit.

Also, I'd rather do PHP than JS or, gods forbid, Java... (I know, I'm biased but Java is actually at the bottom of programming languages I'd like to work with and I've tried out quite a lot of them over the past years)
Time is precious. Waste it wisely.
Birdie
Profile Blog Joined August 2007
New Zealand4438 Posts
November 25 2016 00:47 GMT
#16039
Anyone know of some good quality starter resources for responsive web design? Not using any libraries like bootstrap.
Red classic | A butterfly dreamed he was Zhuangzi | 4.5k, heading to 5k as support!
Manit0u
Profile Blog Joined August 2004
Poland17243 Posts
Last Edited: 2016-11-25 02:51:08
November 25 2016 02:47 GMT
#16040
On November 25 2016 09:47 Birdie wrote:
Anyone know of some good quality starter resources for responsive web design? Not using any libraries like bootstrap.


Bootstrap is probably the best for starters since many products are using it and many other libraries are based on it (foundation, materialize, etc.). As an added bonus you have plenty of resources for that online.

May I ask why no libraries? There is very little point to reinventing the wheel if it's not absolutely necessary.

What kind of resources do you need exactly? General tips and tricks? Something like Google's material design guides? html5rocks? csstricks?
Time is precious. Waste it wisely.
Prev 1 800 801 802 803 804 1031 Next
Please log in or register to reply.
Live Events Refresh
FEL
16:00
Cracov 2025: Qualifier #1
RotterdaM825
IndyStarCraft 281
CranKy Ducklings212
Liquipedia
PSISTORM Gaming Misc
15:55
FSL team league: ASP vs PTB
Freeedom9
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 825
IndyStarCraft 281
JuggernautJason82
ProTech60
StarCraft: Brood War
Calm 4614
firebathero 298
JulyZerg 133
BRAT_OK 95
Rock 38
LancerX 14
Stormgate
Nathanias44
Dota 2
monkeys_forever211
LuMiX1
League of Legends
Grubby2300
Dendi1486
Counter-Strike
fl0m1952
Super Smash Bros
Westballz39
Heroes of the Storm
Khaldor330
Liquid`Hasu281
Other Games
FrodaN1489
Mlord584
KnowMe128
Trikslyr46
Sick45
Organizations
Other Games
EGCTV1382
StarCraft 2
angryscii 17
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 24 non-featured ]
StarCraft 2
• Berry_CruncH71
• printf 70
• tFFMrPink 24
• iHatsuTV 9
• OhrlRock 3
• Kozan
• Migwel
• sooper7s
• AfreecaTV YouTube
• intothetv
• IndyKCrew
• LaughNgamezSOOP
StarCraft: Brood War
• Azhi_Dahaki30
• Pr0nogo 2
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• masondota2820
• WagamamaTV663
• Ler97
League of Legends
• Jankos1813
• Doublelift1602
Other Games
• imaqtpie966
• Shiphtur491
Upcoming Events
RSL Revival
14h 45m
Clem vs Classic
SHIN vs Cure
FEL
16h 45m
WardiTV European League
16h 45m
BSL: ProLeague
22h 45m
Dewalt vs Bonyth
Replay Cast
2 days
Sparkling Tuna Cup
2 days
WardiTV European League
2 days
The PondCast
3 days
Replay Cast
4 days
RSL Revival
4 days
[ Show More ]
Replay Cast
5 days
RSL Revival
5 days
FEL
5 days
RSL Revival
6 days
FEL
6 days
FEL
6 days
Liquipedia Results

Completed

BSL 2v2 Season 3
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL Season 20
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Championship of Russia 2025
RSL Revival: Season 1
Murky Cup #2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025

Upcoming

2025 ACS Season 2: Qualifier
CSLPRO Last Chance 2025
2025 ACS Season 2
CSLPRO Chat StarLAN 3
K-Championship
uThermal 2v2 Main Event
SEL Season 2 Championship
FEL Cracov 2025
Esports World Cup 2025
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.