Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / AGK - I want to swap sprites week about from the start of year.

Author
Message
yoda333
12
Years of Service
User Offline
Joined: 3rd Apr 2012
Location:
Posted: 26th Sep 2013 15:42
Hi

Using AppGameKit, I would like to swap sprites week about from the start of year.

if odd week show sprite1
if even week show sprite2

I hope this question makes sense?

Cheers
Vic
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 26th Sep 2013 15:55
Well, really you need a number to represent the day - in M$ programming languages and systems like Excel, that would be easy. I'm not sure how you'll do that in AppGameKit, hopefully there are some commands that I just haven't noticed yet. You need the number of days passed since a specific date, like the first day of week 1 this year.

Anyway, once you have the day number, just divide by 7 and check whether or not it's odd...

Weeknum=Daynum/7
if Weeknum=floor(Weeknum/2)*2 then weekodd=0 else weekodd=1

I'll have a look when I get a chance, if I find some commands to help, I'll post a better example. There is a thread about date formatting in the forum, maybe that has some useful info.

I am the one who knocks...
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 26th Sep 2013 17:35 Edited at: 26th Sep 2013 17:36
It is awkward, but, you can use a combination of GetCurrentDate() and GetUnixFromDate to do things.

Something like this:


Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
yoda333
12
Years of Service
User Offline
Joined: 3rd Apr 2012
Location:
Posted: 27th Sep 2013 01:58 Edited at: 27th Sep 2013 02:00
Thanks very much Ancient Lady and VanB

Ancient ladie's code snippet works well. I was going to create an array to count the days of the months based on leap year or not leap year and add the days of the current month, but it appears that an array is not currently an option.

Thanks very much for the help

Cheers
Vic
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 27th Sep 2013 03:56
Glad to be of help.

Happy Programming!

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master

Login to post a reply

Server time is: 2024-05-09 05:00:14
Your offset time is: 2024-05-09 05:00:14