On-line: гостей 0. Всего: 0 [подробнее..]
АвторСообщение
администратор




Сообщение: 79
Зарегистрирован: 19.05.07
Рейтинг: 0
ссылка на сообщение  Отправлено: 28.05.07 13:21. Заголовок: Исходники Dark Basic


Стабилизация Скорости:
`скорость игры:
fps_UPS=60
fps_period=1000/fps_UPS
fps_time=timer()-fps_period
do
Repeat
fps_elapsed=timer()-fps_time
Until fps_elapsed
fps_ticks=fps_elapsed/fps_period
For fps_f=1 To fps_ticks
fps_time=fps_time+fps_period
`Отводит на основной цикл:
gosub CiklGames
Next fps_f
sync
loop
`Здесь код игры:
CiklGames:
return

Эффект волн:
Make matrix 1,1000,1000,40,40
do
w=w+1
for wx=0 to 30
for wz=0 to 30
set matrix height 1,wx,wz,sin((wx*10+w)*12)
next wz
next wx
if w=30 then w=0
update matrix 1
loop

Определение координат матрицы под курсором:
Вот функция для определения точки матрицы под курсором:

CODE
function mmcoord(object,scrx#,scry#,matnum,msizex#,msizez#,r#,FOV#)
ax#=camera angle x()
ay#=camera angle y()
scrw#=screen width()
scrh#=screen height()
hmax# = r#*tan(FOV#/2)
mh# = (((scrh#/2-scry#)*2)/scrh#)*hmax#
wmax# = r#*scrw#/scrh#*tan(FOV#/2)
mw# = (((scrx#-scrw#/2)*2)/scrw#)*wmax#
cl# = r#*cos(ax#)
ch# = (-1*r#)*sin(ax#)
sl# = mh#*cos(90-ax#)
sh# = mh#*sin(90-ax#)
ox# = camera position x() + (cl#+sl#)*sin(ay#) + mw#*cos(ay#)
oy# = camera position y() + (ch#+sh#)
oz# = camera position z() + (cl#+sl#)*cos(ay#) - mw#*sin(ay#)
i#=0
while i#<1
x# = camera position x() + (ox#-camera position x())*i#
y# = camera position y() + (oy#-camera position y())*i#
z# = camera position z() + (oz#-camera position z())*i#
mpx# = matrix position x(matnum)
mpz# = matrix position z(matnum)
mpy# = matrix position y(matnum)
if x#>=mpx# and x#<=mpx#+msizex# and z#>=mpz# and z#<=mpz#+msizez#
if y#-mpy#+get ground height(matnum,x#,z#)<=0.0
position object object, x#,get matrix height(matnum, x#, z#), z#
exitfunction
endif
ENDIF
i#=i#+(1.0/r#)
endwhile
endfunction

В этой функции:Object - номер объекта, который ставится под курсор
scrx# - Координата курсора по оси X
scry# - Координата курсора по оси Y
matnum - Номер матрицы, на которой определяются координаты
msizex# - Размер матрицы, но которой определяются координаты, по оси X
msizez# - Размер матрицы, но которой определяются координаты, по оси Z
r# - Дальность рендеринга камеры
FOV# - Вроде бы угол обзора камеры.

Надо учитывать, что при использовании этой функции в ДБклассик, все передаваемые значения должны строго соответствовать по типу с объявленными в переменной. Т.е. координаты курсора по оси X и Y должны быть вещественными. Эту функции можно использовать и в ДБпро, там не обязательно строгое соответствие параметров функции. Примечание: При большом удалении точки от камеры (например вид от 1-го лица при большой дистанции обзора камеры) функция начинает тормозить. В ДБпро это не сильно влияет на производительность, но в ДБклассик заметно.

Загрузка шрифта из картинки:
`========================
================= Загружает шрифты из 'изображения
`FontNum - номер шрифта,
'FontFile$ - название файла
function LoadImageFont(FontNum,FontFile$)
load image FontFile$,29999
paste image 29999,0,0
StartImage=30000+(FontNum*256)
x=0
y=0
for a=StartImage to StartImage+223
get image a,x,y,x+32,y+32
x=x+32
if x=512 then y=y+32:x=0
next a
cls
delete image 29999
endfunction
`====================
`Создает текст из шрифтов-изображений
`Texture - номер создаваемой текстуры,
'Text$ - текст, FontNum - номер шрифта,
'Distance - 'расстояние между символами
`Center - центрировать текст,
'XSize,Ysize - размеры создаваемой текстуры
function MakeTFIF(Texture,Text$,FontNum,Distance,Center,XSize,YSize)
StartImage=30000+(FontNum*256)
x=0:y=0
for a=1 to len(Text$)
Symbol=asc(mid$(Text$,a))
if Symbol=32 then Width=8:`
if Symbol=33 then Width=4:`!
if Symbol=34 then Width=10:`"
if Symbol=35 then Width=15:`#
if Symbol=36 then Width=12:`$
if Symbol=37 then Width=22:`%
if Symbol=38 then Width=18:`&
if Symbol=39 then Width=4:`'
if Symbol=40 then Width=7:`(
if Symbol=41 then Width=7:`)
if Symbol=42 then Width=10:`*
if Symbol=43 then Width=14:`+
if Symbol=44 then Width=4:`,
if Symbol=45 then Width=8:`-
if Symbol=46 then Width=4:`.
if Symbol=47 then Width=8:`/
if Symbol=48 then Width=13:`0
if Symbol=49 then Width=9:`1
if Symbol=50 then Width=13:`2
if Symbol=51 then Width=13:`3
if Symbol=52 then Width=14:`4
if Symbol=53 then Width=13:`5
if Symbol=54 then Width=13:`6
if Symbol=55 then Width=13:`7
if Symbol=56 then Width=13:`8
if Symbol=57 then Width=13:`9
if Symbol=58 then Width=4:`:
if Symbol=59 then Width=4:`;
if Symbol=60 then Width=13:`<
if Symbol=61 then Width=14:`=
if Symbol=62 then Width=13:`>
if Symbol=63 then Width=14:`?
if Symbol=64 then Width=25:`@
if Symbol=65 then Width=19:`A
if Symbol=66 then Width=17:`B
if Symbol=67 then Width=18:`C
if Symbol=68 then Width=17:`D
if Symbol=69 then Width=15:`E
if Symbol=70 then Width=14:`F
if Symbol=71 then Width=18:`G
if Symbol=72 then Width=16:`H
if Symbol=73 then Width=4:`I
if Symbol=74 then Width=13:`J
if Symbol=75 then Width=17:`K
if Symbol=76 then Width=14:`L
if Symbol=77 then Width=19:`M
if Symbol=78 then Width=16:`N
if Symbol=79 then Width=19:`O
if Symbol=80 then Width=15:`P
if Symbol=81 then Width=20:`Q
if Symbol=82 then Width=18:`R
if Symbol=83 then Width=16:`S
if Symbol=84 then Width=16:`T
if Symbol=85 then Width=16:`U
if Symbol=86 then Width=17:`V
if Symbol=87 then Width=25:`W
if Symbol=88 then Width=16:`X
if Symbol=89 then Width=18:`Y
if Symbol=90 then Width=16:`Z
if Symbol=91 then Width=7:`[
if Symbol=92 then Width=8:`\
if Symbol=93 then Width=7:`]
if Symbol=94 then Width=12:`^
if Symbol=95 then Width=16:`_
if Symbol=96 then Width=6:``
if Symbol=97 then Width=13:`a
if Symbol=98 then Width=14:`b
if Symbol=99 then Width=13:`c
if Symbol=100 then Width=14:`d
if Symbol=101 then Width=13:`e
if Symbol=102 then Width=9:`f
if Symbol=103 then Width=14:`g
if Symbol=104 then Width=13:`h
if Symbol=105 then Width=4:`i
if Symbol=106 then Width=7:`j
if Symbol=107 then Width=12:`k
if Symbol=108 then Width=4:`l
if Symbol=109 then Width=22:`m
if Symbol=110 then Width=13:`n
if Symbol=111 then Width=15:`o
if Symbol=112 then Width=14:`p
if Symbol=113 then Width=14:`q
if Symbol=114 then Width=9:`r
if Symbol=115 then Width=13:`s
if Symbol=116 then Width=9:`t
if Symbol=117 then Width=13:`u
if Symbol=118 then Width=13:`v
if Symbol=119 then Width=21:`w
if Symbol=120 then Width=13:`x
if Symbol=121 then Width=15:`y
if Symbol=122 then Width=12:`z
if Symbol=123 then Width=9:`{
if Symbol=124 then Width=3:`|
if Symbol=125 then Width=9:`}
if Symbol=126 then Width=14:`~
if Symbol=127 then Width=14:`
if Symbol=128 then Width=23:`Ђ
if Symbol=129 then Width=13:`Ѓ
if Symbol=130 then Width=4:`‚
if Symbol=131 then Width=9:`ѓ
if Symbol=132 then Width=10:`„
if Symbol=133 then Width=22:`…
if Symbol=134 then Width=14:`†
if Symbol=135 then Width=14:`‡
if Symbol=136 then Width=15:`?
if Symbol=137 then Width=28:`‰
if Symbol=138 then Width=29:`Љ
if Symbol=139 then Width=7:`‹
if Symbol=140 then Width=26:`Њ
if Symbol=141 then Width=14:`Ќ
if Symbol=142 then Width=22:`Ћ
if Symbol=143 then Width=16:`Џ
if Symbol=144 then Width=15:`ђ
if Symbol=145 then Width=4:`‘
if Symbol=146 then Width=4:`’
if Symbol=147 then Width=10:`“
if Symbol=148 then Width=10:`”
if Symbol=149 then Width=8:`•
if Symbol=150 then Width=15:`–
if Symbol=151 then Width=27:`—
if Symbol=152 then Width=14:`?
if Symbol=153 then Width=19:`™
if Symbol=154 then Width=25:`љ
if Symbol=155 then Width=7:`›
if Symbol=156 then Width=21:`њ
if Symbol=157 then Width=12:`ќ
if Symbol=158 then Width=15:`ћ
if Symbol=159 then Width=13:`џ
if Symbol=160 then Width=8:`
if Symbol=161 then Width=17:`Ў
if Symbol=162 then Width=15:`ў
if Symbol=163 then Width=13:`Ј
if Symbol=164 then Width=14:`¤
if Symbol=165 then Width=10:`Ґ
if Symbol=166 then Width=3:`¦
if Symbol=167 then Width=13:`§
if Symbol=168 then Width=15:`Ё
if Symbol=169 then Width=20:`©
if Symbol=170 then Width=17:`Є
if Symbol=171 then Width=13:`«
if Symbol=172 then Width=14:`¬
if Symbol=173 then Width=8:`
if Symbol=174 then Width=20:`®
if Symbol=175 then Width=9:`Ї
if Symbol=176 then Width=8:`°
if Symbol=177 then Width=14:`±
if Symbol=178 then Width=4:`І
if Symbol=179 then Width=4:`і
if Symbol=180 then Width=9:`ґ
if Symbol=181 then Width=13:`µ
if Symbol=182 then Width=14:`¶
if Symbol=183 then Width=4:`·
if Symbol=184 then Width=13:`ё
if Symbol=185 then Width=27:`№
if Symbol=186 then Width=13:`є
if Symbol=187 then Width=13:`»
if Symbol=188 then Width=7:`ј
if Symbol=189 then Width=16:`Ѕ
if Symbol=190 then Width=13:`ѕ
if Symbol=191 then Width=9:`ї
if Symbol=192 then Width=19:`А
if Symbol=193 then Width=16:`Б
if Symbol=194 then Width=17:`В
if Symbol=195 then Width=13:`Г
if Symbol=196 then Width=18:`Д
if Symbol=197 then Width=15:`Е
if Symbol=198 then Width=24:`Ж
if Symbol=199 then Width=16:`З
if Symbol=200 then Width=15:`И
if Symbol=201 then Width=15:`Й
if Symbol=202 then Width=14:`К
if Symbol=203 then Width=17:`Л
if Symbol=204 then Width=19:`М
if Symbol=205 then Width=16:`Н
if Symbol=206 then Width=19:`О
if Symbol=207 then Width=15:`П
if Symbol=208 then Width=15:`Р
if Symbol=209 then Width=18:`С
if Symbol=210 then Width=16:`Т
if Symbol=211 then Width=17:`У
if Symbol=212 then Width=20:`Ф
if Symbol=213 then Width=16:`Х
if Symbol=214 then Width=17:`Ц
if Symbol=215 then Width=15:`Ч
if Symbol=216 then Width=22:`Ш
if Symbol=217 then Width=24:`Щ
if Symbol=218 then Width=22:`Ъ
if Symbol=219 then Width=22:`Ы
if Symbol=220 then Width=16:`Ь
if Symbol=221 then Width=17:`Э
if Symbol=222 then Width=25:`Ю
if Symbol=223 then Width=17:`Я
if Symbol=224 then Width=13:`а
if Symbol=225 then Width=15:`б
if Symbol=226 then Width=14:`в
if Symbol=227 then Width=9:`г
if Symbol=228 then Width=16:`д
if Symbol=229 then Width=13:`е
if Symbol=230 then Width=20:`ж
if Symbol=231 then Width=12:`з
if Symbol=232 then Width=13:`и
if Symbol=233 then Width=13:`й
if Symbol=234 then Width=12:`к
if Symbol=235 then Width=15:`л
if Symbol=236 then Width=17:`м
if Symbol=237 then Width=12:`н
if Symbol=238 then Width=15:`о
if Symbol=239 then Width=12:`п
if Symbol=240 then Width=14:`р
if Symbol=241 then Width=13:`с
if Symbol=242 then Width=12:`т
if Symbol=243 then Width=15:`у
if Symbol=244 then Width=22:`ф
if Symbol=245 then Width=13:`х
if Symbol=246 then Width=14:`ц
if Symbol=247 then Width=12:`ч
if Symbol=248 then Width=18:`ш
if Symbol=249 then Width=20:`щ
if Symbol=250 then Width=17:`ъ
if Symbol=251 then Width=19:`ы
if Symbol=252 then Width=14:`ь
if Symbol=253 then Width=13:`э
if Symbol=254 then Width=20:`ю
if Symbol=255 then Width=14:`я
Image=StartImage+Symbol-32
paste image Image,x,0,1
x=x+Width+Distance
next a
x=x-Distance
get image Texture,0,0,x,32
cls
if center=1 then x=(XSize-x)/2 else x=0
paste image Texture,x,(YSize/2)-16
get image Texture,0,0,XSize,YSize
cls
endfunction
`==================
`== Удалить шрифт
`FontNum - Номер шрифта
function DeleteImageFont(FontNum)
StartImage=30000+(FontNum*256)
for a=StartImage to StartImage+223
delete image a
next a
endfunction


Спасибо: 0 
ПрофильЦитата Ответить
Новых ответов нет


Ответ:
1 2 3 4 5 6 7 8 9
большой шрифт малый шрифт надстрочный подстрочный заголовок большой заголовок видео с youtube.com картинка из интернета картинка с компьютера ссылка файл с компьютера русская клавиатура транслитератор  цитата  кавычки моноширинный шрифт моноширинный шрифт горизонтальная линия отступ точка LI бегущая строка оффтопик свернутый текст

показывать это сообщение только модераторам
не делать ссылки активными
Имя, пароль:      зарегистрироваться    
Тему читают:
- участник сейчас на форуме
- участник вне форума
Все даты в формате GMT  3 час. Хитов сегодня: 0
Права: смайлы да, картинки да, шрифты да, опрос нет
аватары да, автозамена ссылок вкл, премодерация откл, правка нет



WireNet (Phoenomix)

WireNet (Phoenomix)
Клуб профессиональной дрессировки собак Tools of Death - Энциклопедия орудий смерти! Сайт затрагивает тему смерти, и все что с ней связано. Рассматривается все то, что нас убивает. Создай свою игру или скачай готовую Создание сайтов, анимаций, потретов. Уникальные рисованные сайты Мужской форум SmehOff Фан-форум Уилла Смита Обмен кнопочками находится здесь! Заходите и станьте нашим другом!
Первый электротехнический поиск TOPlist минск, поиск информации