Re: 冒昧請教高手有關遊戲的程式設計....
※ 引述《kingstong (卍解-天鎖斬月)》之銘言:
: 我只知道要製作遊戲需先在電腦繪畫圖檔(單機遊戲)
: 然後再利用程式將圖檔與程式做連結.......
: 有人是使用DirectX,但我想知道在dos時代時
: 到底是怎麼寫遊戲.....就像大宇的軒轅劍
: 或是仙劍奇俠傳等...還望高手賜教,感激不盡
經典遊戲,金庸群俠傳總玩過吧
http://goo.gl/oYYUR
這裡有原始碼,用 C 語言寫,一樣從 main 開始
int main(int argc, char* argv[])
#endif
{
srand(clock());
InitialFont();
InitialVedio();
InitialAudio();
Start();
Quit();
return 0;
}
然後這個專案畫圖是用 SDL 畫的:http://goo.gl/Lzugi
====
而 DOS 基本就兩種顯示模式,文字模式、繪圖模式。
平常剛開玩機,就文字模式,這時只能顯示些文字,然後你要畫圖就是用 CPU 指令 int
呼叫中斷,進入繪圖模式,進入後就可以有比如 320 X 200 像素
然後你畫圖時就是一個像素一個像素去設定,比如 X 座標 = 10, Y 座標 = 20 時
顏色要採用比如黃色...
DOS 繪圖範例程式碼:http://ubuntuone.com/p/17bB/
====
補充:備份一下上面網址內的程式碼,以免砍檔後看不到
Plotting a pixel
An easy way to plot a pixel is by using function 0x0C under BIOS interrupt
0x10. For this function, set CX
and DXto the pixel xand ylocation. The color displayed depends on the value
in AL. See Table I for a list
of common colors.
union REGS regs;
regs.h.ah = 0x0C; /* function 0Ch = pixel plot */
regs.h.al = color;
regs.x.cx = x; /* x location, from 0..319 */
regs.x.dx = y; /* y location, from 0..199 */
int86(0x10,®s,®s);
Plotting a pixel quickly
typedef unsigned char byte;
byte far *VGA = (byte far*)0xA0000000L;
unsigned short offset;
/* ... */
offset = 320*y + x;
VGA[offset] = color;
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 124.8.138.160
※ 編輯: purpose 來自: 124.8.138.160 (01/24 21:10)
推
01/24 23:56, , 1F
01/24 23:56, 1F
→
01/25 22:54, , 2F
01/25 22:54, 2F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 3 篇):
Programming 近期熱門文章
PTT數位生活區 即時熱門文章