• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 20:03
CEST 02:03
KST 09:03
  • 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
Team TLMC #5 - Finalists & Open Tournaments0[ASL20] Ro16 Preview Pt2: Turbulence10Classic Games #3: Rogue vs Serral at BlizzCon9[ASL20] Ro16 Preview Pt1: Ascent10Maestros of the Game: Week 1/Play-in Preview12
Community News
StarCraft II 5.0.15 PTR Patch Notes49BSL 2025 Warsaw LAN + Legends Showmatch0Weekly Cups (Sept 8-14): herO & MaxPax split cups4WardiTV TL Team Map Contest #5 Tournaments1SC4ALL $6,000 Open LAN in Philadelphia8
StarCraft 2
General
StarCraft II 5.0.15 PTR Patch Notes #1: Maru - Greatest Players of All Time Weekly Cups (Sept 8-14): herO & MaxPax split cups Team Liquid Map Contest #21 - Presented by Monster Energy SpeCial on The Tasteless Podcast
Tourneys
SC2's Safe House 2 - October 18 & 19 RSL: Revival, a new crowdfunded tournament series Maestros of The Game—$20k event w/ live finals in Paris Sparkling Tuna Cup - Weekly Open Tournament SC4ALL $6,000 Open LAN in Philadelphia
Strategy
Custom Maps
External Content
Mutation # 491 Night Drive Mutation # 490 Masters of Midnight Mutation # 489 Bannable Offense Mutation # 488 What Goes Around
Brood War
General
ASL20 General Discussion Soulkey on ASL S20 BW General Discussion ASL TICKET LIVE help! :D NaDa's Body
Tourneys
[ASL20] Ro16 Group C [ASL20] Ro16 Group D Small VOD Thread 2.0 [Megathread] Daily Proleagues
Strategy
Simple Questions, Simple Answers Muta micro map competition Fighting Spirit mining rates [G] Mineral Boosting
Other Games
General Games
Stormgate/Frost Giant Megathread Borderlands 3 Path of Exile Nintendo Switch Thread General RTS Discussion Thread
Dota 2
Official 'what is Dota anymore' discussion LiquidDota to reintegrate into TL.net
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
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread UK Politics Mega-thread Canadian Politics Mega-thread
Fan Clubs
The Happy Fan Club!
Media & Entertainment
Movie Discussion! [Manga] One Piece Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion MLB/Baseball 2023
World Cup 2022
Tech Support
Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread High temperatures on bridge(s)
TL Community
BarCraft in Tokyo Japan for ASL Season5 Final The Automated Ban List
Blogs
i'm really bored guys
Peanutsc
I <=> 9
KrillinFromwales
The Personality of a Spender…
TrAiDoS
A very expensive lesson on ma…
Garnet
hello world
radishsoup
Lemme tell you a thing o…
JoinTheRain
RTS Design in Hypercoven
a11
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1563 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
Poland17342 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
Poland17342 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
Hyrule19087 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
Spain18051 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
Hyrule19087 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
Poland17342 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
Poland17342 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
Jollibee19350 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
Poland17342 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
Poland17342 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
Next event in 9h 57m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SteadfastSC 168
SpeCial 92
ROOTCatZ 83
CosmosSc2 53
RuFF_SC2 18
StarCraft: Brood War
Britney 12153
Artosis 682
Shuttle 389
Aegong 72
Sexy 54
Dota 2
monkeys_forever786
NeuroSwarm204
League of Legends
JimRising 1051
Counter-Strike
Stewie2K485
Super Smash Bros
Mew2King49
Other Games
summit1g7524
shahzam896
C9.Mang0210
Trikslyr47
ViBE43
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• davetesta35
• intothetv
• AfreecaTV YouTube
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• HerbMon 12
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Doublelift5601
Other Games
• Scarra1493
• imaqtpie1389
• Shiphtur262
Upcoming Events
RSL Revival
9h 57m
Zoun vs Classic
Map Test Tournament
10h 57m
Korean StarCraft League
1d 2h
BSL Open LAN 2025 - War…
1d 7h
RSL Revival
1d 9h
Reynor vs Cure
BSL Open LAN 2025 - War…
2 days
RSL Revival
2 days
Online Event
2 days
Wardi Open
3 days
Monday Night Weeklies
3 days
[ Show More ]
Sparkling Tuna Cup
4 days
LiuLi Cup
5 days
The PondCast
6 days
Liquipedia Results

Completed

Proleague 2025-09-10
Chzzk MurlocKing SC1 vs SC2 Cup #2
HCC Europe

Ongoing

BSL 20 Team Wars
KCM Race Survival 2025 Season 3
BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
LASL Season 20
RSL Revival: Season 2
Maestros of the Game
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

Upcoming

2025 Chongqing Offline CUP
BSL World Championship of Poland 2025
IPSL Winter 2025-26
BSL Season 21
SC4ALL: Brood War
BSL 21 Team A
Stellar Fest
SC4ALL: StarCraft II
EC S1
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
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.