Dennis
Loyalty Card Holder
Posts: 84
Registered: 26-2-2016
Location: Belgium
Member Is Offline
|
|
Code snippet: Writing letter per letter on screen
I wrote this thing that makes text appear on the screen letter by letter.
I called it "Flash write" but call it whatever you want
include this process in your code:
Code: |
/*
Parameters:
font,x,y,center : the same input parameters as "write()"
speed : The amount of frames is between printing a character on screen
pointer text id: the id of the text written on screen is passed via this pointer
*/
process flash_write(font,x,y,center,string text,speed,pointer text_id)
private
i;
len;
string new_text;
begin
len = strlen(text);
*text_id=write(font,x,y,center,new_text);
for (i=0;i<len;i++)
strcat(new_text,*text[i]);
frame(speed*100);
end
end
|
Example how to call it:
Code: |
flash_write(0,160,100,4,"This is text",3,&text_id); // prints the text, a character every 3 frames
repeat frame; until(key(_enter))
delete_text(text_id); // removes the text
|
The code should work, but tell me if you have problems with it.
PS: Maybe we could have a seperate section for code snippets?
|
|
MikeDX
|
|
Very nice, and yes we can.
|
|
BreadCaster
Loyalty Card Holder
Posts: 321
Registered: 2-3-2016
Member Is Offline
|
|
This is a fantastic idea, Dennis - and thanks Mike for making the subforum.
I was actually watching Extra Credits the other day, they did a session on creating your first game - and one of the things they said is how
these days a lot of programming languages have resource sharing sections/places where you can pick up code snippets, models, 2D graphics and audio
either for free or for a small fixed amount. Often it means that rather than spending weeks stuck on a piece of code or making a model that would take
forever, someone else will already have the code and you can pick it up for free or a few bucks - solving the thing which would take forever to do
yourself if you're less skilled in the area.
While all languages can draw on the same content - audio, 3d models, artwork, music etc (and I might actually do a post tonight, sharing the ones I
know) - I thought to myself, "there isn't a strong enough background of people who know how to code in DIV/DIVDX to have established any 'code
snippets' yet..." - and one of the strengths of more popular game creation tools like Unity, for instance, is that if you're really stuck then the
code will likely already be floating around somewhere if it's a common task. This helps them become more commonly used and therefore more people write
games in them and code snippets in them.
Anyway, what I mean is that having a good bunch of code snippets written for/in DIV (possibly for a small price or for free) could help it become a
much more popular language for the hobbyists out there who're just starting out :D
Also, Dennis - I made some code like this for the game I'm currently tweaking/messing around with - it's much less efficient than yours.
~*~ Princess of Pies and Pastries ~*~
|
|
Dennis
Loyalty Card Holder
Posts: 84
Registered: 26-2-2016
Location: Belgium
Member Is Offline
|
|
Why thank you. That'll be 16 dollars.
Just kidding.
This thing popped in my mind because I was trying to make a blinking text (that's why it's called flash_write)
I hope many others will post snippets too!
がんばってください!
|
|
BreadCaster
Loyalty Card Holder
Posts: 321
Registered: 2-3-2016
Member Is Offline
|
|
You joke but, imagine if there were a piece of code to cull polygons from the immediate area where the player wasn't looking. Like if someone wrote
that as a function. I'd happily pay for that :p
Personally I'd love it if there were some network play code snippets, as I can't seem to get it working myself!
~*~ Princess of Pies and Pastries ~*~
|
|
MikeDX
|
|
Breadmaster the new network api in div will be dead easy to use.
|
|
BreadCaster
Loyalty Card Holder
Posts: 321
Registered: 2-3-2016
Member Is Offline
|
|
holy [Censored] I am actually stoked now :D
~*~ Princess of Pies and Pastries ~*~
|
|
Dennis
Loyalty Card Holder
Posts: 84
Registered: 26-2-2016
Location: Belgium
Member Is Offline
|
|
Holy censored! That's awesome! I will make a great network game then!
|
|
BreadCaster
Loyalty Card Holder
Posts: 321
Registered: 2-3-2016
Member Is Offline
|
|
I already have a partly made network game at the ready!! ... well, a scrolling starfield and a few menus with text input/strings to enter the IP, but
they set the tone for the game very well - just waiting for the network module to be perfected so it can be properly made :D
~*~ Princess of Pies and Pastries ~*~
|
|
MikeDX
|
|
Best get cracking bready, the network works
|
|
BreadCaster
Loyalty Card Holder
Posts: 321
Registered: 2-3-2016
Member Is Offline
|
|
Finishing the other game I'm working on first :p as it's much further along.
how much information will we need to join a game? Port and IP address to join to another PC?
~*~ Princess of Pies and Pastries ~*~
|
|
MikeDX
|
|
Don't need any port or ip or none of that nonsense
you just give your game a name, setup a struct and call net_join_game() to get your player id
|
|
BreadCaster
Loyalty Card Holder
Posts: 321
Registered: 2-3-2016
Member Is Offline
|
|
Quote: Originally posted by MikeDX | Don't need any port or ip or none of that nonsense
you just give your game a name, setup a struct and call net_join_game() to get your player id |
hmm alright. I had a very nicely 80s tech retro-themed IP and PORT entry screen with an old fashioned modem sound, looked like something out of Alien,
all ready to go, but I guess that's all superfluous to requirements now!
~*~ Princess of Pies and Pastries ~*~
|
|
MikeDX
|
|
Well there will still be the need to join other lobbies I guess since at the moment each game just gets joined on a matchmaking process. It's all
still a bit WIP at the moment but the key thing is that it *must* be easy to use.
|
|
BreadCaster
Loyalty Card Holder
Posts: 321
Registered: 2-3-2016
Member Is Offline
|
|
I could modify it so you can either directly connect to another PC, or go to a lobby? It's already coded with the option for the PC it's being played
on to either be client or server side, so I could just recycle that code/option...
~*~ Princess of Pies and Pastries ~*~
|
|
MikeDX
|
|
Well, there are some net.* options that can be tweaked but they are currently configured for old IPX / Modem configuration so anything is possible
really. maybe different modes, 1 - matchmaking, 2 - p2p, etc
|
|
BreadCaster
Loyalty Card Holder
Posts: 321
Registered: 2-3-2016
Member Is Offline
|
|
That would be great - I mean, the game is incredibly simple, it's a 1v1 horror themed space sim. No AI, not much in terms of gameplay, it's all about
the atmosphere - which is why I was a little worried about losing the menu so far as it does a great job of helping set the mood haha
~*~ Princess of Pies and Pastries ~*~
|
|
Dennis
Loyalty Card Holder
Posts: 84
Registered: 26-2-2016
Location: Belgium
Member Is Offline
|
|
Broadcaster: Screenshots? :D
|
|